diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-15 23:37:38 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-15 23:37:38 -0700 |
commit | 5c2219772a300ca26cab1e71f8d4d73f34cf1ff0 (patch) | |
tree | 8992be68d669c5a1bee40383953bb2c659e1cd3b | |
parent | 4f5b3ab1273a8111a60c2a55cd31529a71f4dfa0 (diff) | |
download | txr-5c2219772a300ca26cab1e71f8d4d73f34cf1ff0.tar.gz txr-5c2219772a300ca26cab1e71f8d4d73f34cf1ff0.tar.bz2 txr-5c2219772a300ca26cab1e71f8d4d73f34cf1ff0.zip |
args: don't use C99 flexible array member.
The reason is that args_decl_list places struct args
inside a larger struct, where it is followed by another
member. A struct with a flexible array being other than
the last member of another struct is a GNU extension,
which generates warnings on newer GCC versions.
* args.h (struct args): Define arg as array of [1]
rather than [FLEX_ARRAY].
(ARGS_ABS_MIN): Unconditionally define as 1.
(args_decl_list): Subtract 1 from N because we get
one element from struct args. This macro should have
subtracted the FLEX_ARRAY value.
-rw-r--r-- | args.h | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -30,7 +30,7 @@ struct args { cnum argc; cnum fill; val list; - val arg[FLEX_ARRAY]; + val arg[1]; /* deliberate disuse of FLEX_ARRAY */ }; typedef int arg_index; @@ -38,11 +38,7 @@ typedef int arg_index; #define ARGS_MAX 32 #define ARGS_MIN 4 -#if FLEX_ARRAY + 0 == 1 #define ARGS_ABS_MIN 1 -#else -#define ARGS_ABS_MIN 0 -#endif struct args_bool_key { val key; @@ -64,7 +60,7 @@ INLINE void args_set_fill(struct args *args, cnum fill) } #define args_decl_list(NAME, N, L) \ - struct { struct args args; val arg[N]; } _ac; \ + struct { struct args args; val arg[(N) - 1]; } _ac; \ struct args *NAME = args_init_list(&_ac.args, N, L) #define args_decl_constsize(NAME, N) args_decl_list(NAME, N, nil) |