Norman James | 6a58a27 | 2015-10-07 14:34:16 -0500 | [diff] [blame] | 1 | #include <ccan/container_of/container_of.h>
|
| 2 | #include <stdlib.h>
|
| 3 |
|
| 4 | struct foo {
|
| 5 | int a;
|
| 6 | char b;
|
| 7 | };
|
| 8 |
|
| 9 | int main(int argc, char *argv[])
|
| 10 | {
|
| 11 | struct foo foo = { .a = 1, .b = 2 }, *foop;
|
| 12 | int *intp = &foo.a;
|
| 13 |
|
| 14 | #ifdef FAIL
|
| 15 | /* b is a char, but intp is an int * */
|
| 16 | foop = container_of(intp, struct foo, b);
|
| 17 | #else
|
| 18 | foop = NULL;
|
| 19 | #endif
|
| 20 | (void) foop; /* Suppress unused-but-set-variable warning. */
|
| 21 | return intp == NULL;
|
| 22 | }
|