diff options
author | Thomas Haller <thaller@redhat.com> | 2017-11-10 12:00:09 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-11-13 11:35:44 +0100 |
commit | 557d83bf2ddf832828a9b85ffffcad0b7d88272a (patch) | |
tree | 0a1518dcaff142ba932115558383891d5366abc5 | |
parent | bdfdabea51bb19f9bf9a95a57e80ab98d4b3122f (diff) | |
download | NetworkManager-557d83bf2ddf832828a9b85ffffcad0b7d88272a.tar.gz |
build: detect compiler features _Generic() and __auto_type in configure script
There is still a fallback detection in "shared/nm-utils/nm-macros-internal.h",
so that VPN-plugins and applet don't need to bother about adding these
configure checks.
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | shared/nm-utils/nm-macros-internal.h | 9 |
2 files changed, 24 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index ad188a7763..a2405c625b 100644 --- a/configure.ac +++ b/configure.ac @@ -1227,6 +1227,22 @@ fi AC_SUBST(SANITIZERS, [$sanitizers]) +AC_MSG_CHECKING([CC support C11 _Generic()]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(void); int foo() { int a = 0; int b = _Generic (a, int: 4); return b + a; }]], + [[foo();]])], + [cc_support_generic=1], + [cc_support_generic=0]) +AC_MSG_RESULT($cc_support_generic) +AC_DEFINE_UNQUOTED(_NM_CC_SUPPORT_GENERIC, $cc_support_generic, [Define whether the compiler supports C11 _Generic()]) + +AC_MSG_CHECKING([CC support gcc __auto_type]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(void); int foo() { int a = 0; __auto_type b = a; return b + a; }]], + [[foo();]])], + [cc_support_auto_type=1], + [cc_support_auto_type=0]) +AC_MSG_RESULT($cc_support_auto_type) +AC_DEFINE_UNQUOTED(_NM_CC_SUPPORT_AUTO_TYPE, $cc_support_auto_type, [Define whether the compiler support gcc __auto_type]) + dnl ------------------------- dnl Vala bindings dnl ------------------------- diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h index 49bc79e582..2d62ba7d97 100644 --- a/shared/nm-utils/nm-macros-internal.h +++ b/shared/nm-utils/nm-macros-internal.h @@ -263,18 +263,25 @@ NM_G_ERROR_MSG (GError *error) /*****************************************************************************/ +#ifndef _NM_CC_SUPPORT_AUTO_TYPE #if (defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9 ))) #define _NM_CC_SUPPORT_AUTO_TYPE 1 -#define _nm_auto_type __auto_type #else #define _NM_CC_SUPPORT_AUTO_TYPE 0 #endif +#endif +#ifndef _NM_CC_SUPPORT_GENERIC #if (defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9 ))) || (defined (__clang__)) #define _NM_CC_SUPPORT_GENERIC 1 #else #define _NM_CC_SUPPORT_GENERIC 0 #endif +#endif + +#if _NM_CC_SUPPORT_AUTO_TYPE +#define _nm_auto_type __auto_type +#endif #if _NM_CC_SUPPORT_GENERIC #define _NM_CONSTCAST_FULL_1(type, obj_expr, obj) \ |