From ae13cb3b1bdc76cb48ed991d03b6303aea7ffcb3 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 29 Sep 2021 10:02:39 +0200 Subject: [PATCH] build: compiler attribute improvements Signed-off-by: Christian Brauner --- meson.build | 9 +++++++-- src/lxc/compiler.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index e37c4694b..d832eb8b3 100644 --- a/meson.build +++ b/meson.build @@ -355,8 +355,13 @@ conf.set10('HAVE_STRCHRNUL', have) have = cc.has_function('openpty', prefix : '#include ', args : '-D_GNU_SOURCE') conf.set10('HAVE_OPENPTY', have) -conf.set10('HAVE_COMPILER_ATTR_NONNULL', cc.has_function_attribute('nonnull')) -conf.set10('HAVE_COMPILER_ATTR_RETURNS_NONNULL', cc.has_function_attribute('returns_nonnull')) +foreach ccattr : ['fallthrough', + 'nonnull', + 'returns_nonnull', + ] + + conf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr)) +endforeach config_h = configure_file( output : 'config.h', diff --git a/src/lxc/compiler.h b/src/lxc/compiler.h index ec071dc83..4d6232382 100644 --- a/src/lxc/compiler.h +++ b/src/lxc/compiler.h @@ -18,7 +18,7 @@ #endif #endif -#if __GNUC__ >= 7 +#if HAVE_COMPILER_ATTR_FALLTHROUGH || __GNUC__ >= 7 #define __fallthrough __attribute__((__fallthrough__)) #else #define __fallthrough /* fall through */ -- 2.47.2