aboutsummaryrefslogtreecommitdiffstats
path: root/libsimple-arg.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-11-29 21:25:44 +0100
committerMattias Andrée <maandree@kth.se>2018-11-29 21:25:44 +0100
commita2fc726a6225ceb94dba367cf5acfe597ce11d74 (patch)
tree7e6f705a9160b9bdad8f32463284009085dc7254 /libsimple-arg.h
parentm (diff)
downloadlibsimple-a2fc726a6225ceb94dba367cf5acfe597ce11d74.tar.gz
libsimple-a2fc726a6225ceb94dba367cf5acfe597ce11d74.tar.bz2
libsimple-a2fc726a6225ceb94dba367cf5acfe597ce11d74.tar.xz
A bunch of stuff
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libsimple-arg.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/libsimple-arg.h b/libsimple-arg.h
index 1f4291c..983f4c8 100644
--- a/libsimple-arg.h
+++ b/libsimple-arg.h
@@ -398,8 +398,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
@@ -412,26 +423,15 @@ struct longopt {
* @param SYNOPSIS:const char * Description of the command line argument syntax
* @parma STATUS:int The exit value for the process
*/
-#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