diff options
author | Mattias Andrée <maandree@kth.se> | 2024-08-18 09:43:16 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-08-18 09:43:16 +0200 |
commit | 715b59e5002b971a987c3c8a2e1b3e61d80388f7 (patch) | |
tree | aa64aa9fed94388056432f0f4a2180d5c03523fd /libsimple-arg.h | |
parent | Add @since for definitions added in version 1.0 and 1.1 (diff) | |
parent | Fix tests and libsimple_arraycpy and libsimple_arraymove (diff) | |
download | libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.gz libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.bz2 libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.xz |
Merge tag '1.2' into since
Version 1.2
Diffstat (limited to '')
-rw-r--r-- | libsimple-arg.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libsimple-arg.h b/libsimple-arg.h index 25d4c72..3ffc3ed 100644 --- a/libsimple-arg.h +++ b/libsimple-arg.h @@ -432,8 +432,19 @@ struct longopt { #define USAGE(SYNOPSIS)\ NUSAGE(1, SYNOPSIS) + +/* Intended for internal use only */ +#if __STDC_VERSION__ >= 201112L +# define _LIBSIMPLE_NORETURN _Noreturn +#elif defined(__GNUC__) || defined(__clang__) +# define _LIBSIMPLE_NORETURN __attribute__((noreturn)) +#else +# define _LIBSIMPLE_NORETURN +#endif + + /** - * Define the function `static void usage(void)` + * Define the function `static _Noreturn void usage(void)` * that prints the error message * "usage: %s %s\n", argv0, SYNOPSIS * or @@ -448,26 +459,15 @@ struct longopt { * * @since 1.0 */ -#if defined(__GNUC__) || defined(__clang__) -# define NUSAGE(STATUS, SYNOPSIS)\ - __attribute__((noreturn))\ - static void usage(void)\ - {\ - const char *syn = SYNOPSIS ? SYNOPSIS : "";\ - fprintf(stderr, "usage: %s%s%s\n", argv0, *syn ? " " : "", syn);\ - exit(STATUS);\ - }\ - char *argv0 = NULL -#else -# define NUSAGE(STATUS, SYNOPSIS)\ - static void usage(void)\ +#define NUSAGE(STATUS, SYNOPSIS)\ + static _LIBSIMPLE_NORETURN void\ + usage(void)\ {\ const char *syn = SYNOPSIS ? SYNOPSIS : "";\ fprintf(stderr, "usage: %s%s%s\n", argv0, *syn ? " " : "", syn);\ exit(STATUS);\ }\ char *argv0 = NULL -#endif #endif |