commit ee326112b37d884aad27e52a367c8505e11b2894
parent c17e0cb19fcbfb0cfa02a99bd6f7c051ec07f853
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Fri, 25 Apr 2025 14:24:35 +0200
configure: improved compatibility of compound literal checks
Diffstat:
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -572,6 +572,15 @@ MHD_CHECK_CC_CFLAG([-Wused-but-marked-unused],[CFLAGS_ac],
AC_DEFINE([[HAVE_WUSED_BUT_MARKED_UNUSED]],[[1]],[Define to '1' i][f -Wused-but-marked-unused flag is supported by compiler])
]
)
+AS_UNSET([nocxx_compat_CFLAGS])
+MHD_CHECK_CC_CFLAG([-Wc++-compat],[CFLAGS_ac],
+ [
+ AC_DEFINE([[HAVE_WCXX_COMPAT]],[[1]],[Define to '1' i][f -Wc++-compat flag is supported by compiler])
+ MHD_CHECK_CC_CFLAG([-Wno-c++-compat],[CFLAGS_ac],
+ [nocxx_compat_CFLAGS="-Wno-c++-compat"]
+ )
+ ]
+)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
# Additional flags are checked and added at the end of 'configure'
@@ -1023,6 +1032,8 @@ int main(void)
AS_VAR_IF([mhd_cv_cc_macro_variadic],["yes"],
[AC_DEFINE([HAVE_MACRO_VARIADIC],[1],[Define to '1' if your compiler supports variadic macros])]
)
+
+CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${nocxx_compat_CFLAGS}"
AC_CACHE_CHECK([whether $CC supports compound literals],[mhd_cv_cc_compound_literals],
[
MHD_SAVED_ac_c_werror_flag="$ac_c_werror_flag"
@@ -1071,11 +1082,6 @@ AS_VAR_IF([mhd_cv_cc_compound_literals],["yes"],
AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE([[
-#ifdef __cplusplus
-choke me now; /* Clang++ actually may handle this check properly, but it is too tricky to test it corretly */
-#error This is a C++ compiler
-#endif
-
struct test_strct
{
char c;
@@ -1129,6 +1135,15 @@ int main(void)
return strct_ptr1[1].i == 2 ? 0 : 11;
}
+
+#ifdef __cplusplus
+choke me now; /* Actually, some C++ compilers *may* handle this properly,
+ * but it is too tricky to test it correctly.
+ * False-positive results will lead to run-time errors,
+ * so just block it when C++ is used. */
+#error This is a C++ compiler
+#endif
+
]]
)
],
@@ -1236,6 +1251,7 @@ int main(void)
AS_UNSET([mhd_cv_cc_compound_literals_arr_scope])
]
)
+CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${nocxx_compat_CFLAGS}"
AC_CACHE_CHECK([whether $CC supports trailing comma in enum],[mhd_cv_enum_trailing_comma],
[
SAVE_c_werror_flag="$ac_c_werror_flag"