diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-12-30 16:31:43 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-12-30 16:31:43 +0100 |
commit | b31c642e7177cb718579d4f88ed840ba58f7778d (patch) | |
tree | 16c8fdf81232d25fe87644faa7e275d25dae29b3 | |
parent | 5194e53b23f194a4a3193e495a7ff7478d895de4 (diff) |
Add the _vtoa() macro
-rw-r--r-- | cbs.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -102,6 +102,9 @@ # define _Nullable #endif +/* Convert the given variadic arguments to a string array */ +#define _vtoa(...) ((char *[]){__VA_ARGS__}) + /* Internal global versions of argc and argv, so our functions and macros can access them from anywhere. */ static int _cbs_argc; @@ -152,7 +155,7 @@ typedef struct { the given command. */ static void cmdaddv(cmd_t *, char **p, size_t n); #define cmdadd(cmd, ...) \ - cmdaddv(cmd, ((char *[]){__VA_ARGS__}), lengthof(((char *[]){__VA_ARGS__}))) + cmdaddv(cmd, _vtoa(__VA_ARGS__), lengthof(_vtoa(__VA_ARGS__))) /* Clear (but not free) the command c. Useful for reusing the same command struct to minimize allocations. */ |