compile_fail-tlist_prev2.c 574 B

1234567891011121314151617181920212223242526272829303132
  1. #include <ccan/tlist/tlist.h>
  2. TLIST_TYPE(children, struct child);
  3. struct child {
  4. const char *name;
  5. struct list_node list;
  6. };
  7. struct cousin {
  8. const char *name;
  9. struct list_node list;
  10. };
  11. int main(int argc, char *argv[])
  12. {
  13. struct tlist_children children;
  14. struct child child = { "child" };
  15. #ifdef FAIL
  16. #if !HAVE_FLEXIBLE_ARRAY_MEMBER
  17. #error Need flexible array members to check type
  18. #endif
  19. struct cousin *p = NULL;
  20. #else
  21. struct child *p = NULL;
  22. #endif
  23. tlist_init(&children);
  24. tlist_add(&children, &child, list);
  25. (void)tlist_prev(&children, p, list);
  26. return 0;
  27. }