blob: 9ee8e9fc0e541504bb60c0195f0ae567c5cf65e8 [file] [log] [blame]
Norman James6a58a272015-10-07 14:34:16 -05001#include <ccan/container_of/container_of.h>
2#include <stdlib.h>
3
4struct foo {
5 int a;
6 char b;
7};
8
9int main(int argc, char *argv[])
10{
11 struct foo foo = { .a = 1, .b = 2 };
12 int *intp = &foo.a;
13 char *p;
14
15#ifdef FAIL
16 /* p is a char *, but this gives a struct foo * */
17 p = container_of(intp, struct foo, a);
18#else
19 p = (char *)intp;
20#endif
21 return p == NULL;
22}