]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
configure: add check for C++ constexpr if
authorPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 11 Sep 2025 05:18:52 +0000 (07:18 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Thu, 11 Sep 2025 05:18:52 +0000 (07:18 +0200)
For old compilers like GCC 6.3 that suppoert -std=c++17 but not
constexpr if, which is a 17 feature.

configure.ac

index ee623b050fdc0e7b80b8d8dba5821f5e7f79a40f..21e905fe87643ad01c341e7f86674b02f5ac1bed 100755 (executable)
@@ -1993,6 +1993,31 @@ AC_LANG(C)
 
 AM_CONDITIONAL(HAVE_CXX17, test x$ac_have_cxx_17 = xyes)
 
+AC_MSG_CHECKING([that C++ compiler supports constexpr if])
+AC_LANG(C++)
+safe_CXXFLAGS=$CXXFLAGS
+CXXFLAGS=-std=c++17
+
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+void f()
+{
+   if constexpr (true)
+      ;
+}
+])],
+[
+ac_have_constexpr_if=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_constexpr_if=no
+AC_MSG_RESULT([no])
+                       ])
+CXXFLAGS=$safe_CXXFLAGS
+AC_LANG(C)
+
+AM_CONDITIONAL(HAVE_CONSTEXPR_IF, test x$ac_have_constexpr_if = xyes)
+
+
 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
 AC_LANG(C++)
 safe_CXXFLAGS=$CXXFLAGS