]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
util: Move falltrhough feature check to meson.build
authorTokunori Ikegami <ikegami.t@gmail.com>
Tue, 6 Jun 2023 08:45:43 +0000 (10:45 +0200)
committerDaniel Wagner <wagi@monom.org>
Tue, 6 Jun 2023 09:01:09 +0000 (11:01 +0200)
Instead cluttering the header file, let's add it to meson.build.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
meson.build
util/argconfig.c

index 261128c94676a9ed2d9ecfbfbb372113c04a3eee..944fabc25aaf315d5d9abd480d265d39914cce8d 100644 (file)
@@ -156,6 +156,12 @@ conf.set10(
     description: 'Is sys/random.h(getrandom) include-able?'
 )
 
+if cc.has_function_attribute('fallthrough')
+  conf.set('fallthrough', '__attribute__((__fallthrough__))')
+else
+  conf.set('fallthrough', 'do {} while (0) /* fallthrough */')
+endif
+
 configure_file(
     output: 'config.h',
     configuration: conf
index f101527ef73d60153f9b22d5cda635d2144e081f..effeea2f6aeea2411452b564a51c947ef87066fb 100644 (file)
 #include <string.h>
 #include <stdbool.h>
 
-#if __has_attribute(__fallthrough__)
-#define fallthrough __attribute__((__fallthrough__))
-#else
-#define fallthrough do {} while (0)
-#endif
-
 static const char *append_usage_str = "";
 
 static int argconfig_parse_val(struct argconfig_commandline_options *s, struct option *option,