aboutsummaryrefslogtreecommitdiffstats
path: root/libsimple-arg.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-08-18 09:43:16 +0200
committerMattias Andrée <maandree@kth.se>2024-08-18 09:43:16 +0200
commit715b59e5002b971a987c3c8a2e1b3e61d80388f7 (patch)
treeaa64aa9fed94388056432f0f4a2180d5c03523fd /libsimple-arg.h
parentAdd @since for definitions added in version 1.0 and 1.1 (diff)
parentFix tests and libsimple_arraycpy and libsimple_arraymove (diff)
downloadlibsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.gz
libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.bz2
libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.xz
Merge tag '1.2' into since
Version 1.2
Diffstat (limited to 'libsimple-arg.h')
-rw-r--r--libsimple-arg.h30
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