From 03f100b281441a953d4ec858389f82e25a95c043 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Tue, 23 Aug 2016 02:04:06 +1200 Subject: [PATCH] tlist: Place tlists last in structures TCON suggests placing _tcon members last in structs. Placing variable sized structs anywhere but last is apparently a gcc extension that gives warnings under clang. This applies to tlists because they use TCON internally. Update the docs and examples to place tlists last and so compile without clang warnings. There are other places where this occurs; they will be dealt with separately. Signed-off-by: Jon Griffiths --- ccan/tlist/_info | 2 +- ccan/tlist/test/run.c | 2 +- ccan/tlist/tlist.h | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ccan/tlist/_info b/ccan/tlist/_info index e6b16ef0..4c3394c9 100644 --- a/ccan/tlist/_info +++ b/ccan/tlist/_info @@ -22,8 +22,8 @@ * }; * struct parent { * const char *name; - * struct tlist_children children; * unsigned int num_children; + * struct tlist_children children; * }; * * struct child { diff --git a/ccan/tlist/test/run.c b/ccan/tlist/test/run.c index 06732cc3..d36cd8bc 100644 --- a/ccan/tlist/test/run.c +++ b/ccan/tlist/test/run.c @@ -6,8 +6,8 @@ TLIST_TYPE(children, struct child); struct parent { const char *name; - struct tlist_children children; unsigned int num_children; + struct tlist_children children; }; struct child { diff --git a/ccan/tlist/tlist.h b/ccan/tlist/tlist.h index 28978514..a99191a2 100644 --- a/ccan/tlist/tlist.h +++ b/ccan/tlist/tlist.h @@ -11,15 +11,16 @@ * * This declares a structure "struct tlist_@suffix" to use for * lists containing this type. The actual list can be accessed using - * ".raw" or tlist_raw(). + * ".raw" or tlist_raw(). For maximum portability, place tlists + * embedded in structures as the last member. * * Example: * // Defines struct tlist_children * TLIST_TYPE(children, struct child); * struct parent { * const char *name; - * struct tlist_children children; * unsigned int num_children; + * struct tlist_children children; * }; * * struct child { -- 2.39.2