From: Christian Brauner Date: Wed, 29 Sep 2021 08:02:39 +0000 (+0200) Subject: build: compiler attribute improvements X-Git-Tag: lxc-5.0.0~82^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3983%2Fhead;p=thirdparty%2Flxc.git build: compiler attribute improvements Signed-off-by: Christian Brauner --- 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 */