]> git.ozlabs.org Git - ccan/commitdiff
tlist: Place tlists last in structures
authorJon Griffiths <jon_p_griffiths@yahoo.com>
Mon, 22 Aug 2016 14:04:06 +0000 (02:04 +1200)
committerJon Griffiths <jon_p_griffiths@yahoo.com>
Wed, 24 Aug 2016 06:52:29 +0000 (18:52 +1200)
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 <jon_p_griffiths@yahoo.com>
ccan/tlist/_info
ccan/tlist/test/run.c
ccan/tlist/tlist.h

index e6b16ef0ae2c97f4ac3a8289c05112f5d8ae900f..4c3394c977b5459eec1f7a3ec826cf8142f1728e 100644 (file)
@@ -22,8 +22,8 @@
  *     };
  *     struct parent {
  *             const char *name;
  *     };
  *     struct parent {
  *             const char *name;
- *             struct tlist_children children;
  *             unsigned int num_children;
  *             unsigned int num_children;
+ *             struct tlist_children children;
  *     };
  *
  *     struct child {
  *     };
  *
  *     struct child {
index 06732cc3c1e1b32dccc79677c4c42043c0a77e7d..d36cd8bcd41b456e0c399ce685dc67bdf099f7ff 100644 (file)
@@ -6,8 +6,8 @@ TLIST_TYPE(children, struct child);
 
 struct parent {
        const char *name;
 
 struct parent {
        const char *name;
-       struct tlist_children children;
        unsigned int num_children;
        unsigned int num_children;
+       struct tlist_children children;
 };
 
 struct child {
 };
 
 struct child {
index 28978514678d99a7df24ca66872465cf0cea3586..a99191a2e0ebd75e9b13145550ac90d0a859f72e 100644 (file)
  *
  * This declares a structure "struct tlist_@suffix" to use for
  * lists containing this type.  The actual list can be accessed using
  *
  * 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;
  *
  * Example:
  *     // Defines struct tlist_children
  *     TLIST_TYPE(children, struct child);
  *     struct parent {
  *             const char *name;
- *             struct tlist_children children;
  *             unsigned int num_children;
  *             unsigned int num_children;
+ *             struct tlist_children children;
  *     };
  *
  *     struct child {
  *     };
  *
  *     struct child {