blob: 60f25bd32b63f8ebf316bab429a4b554e5dddd6f [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 }, *foop;
12 int *intp = &foo.a;
13
14#ifdef FAIL
15 /* b is a char, but intp is an int * */
16 foop = container_of_var(intp, foop, b);
17#if !HAVE_TYPEOF
18#error "Unfortunately we don't fail if we don't have typeof."
19#endif
20#else
21 foop = NULL;
22#endif
23 (void) foop; /* Suppress unused-but-set-variable warning. */
24 return intp == NULL;
25}