From d846c37bfac98c77a984011b8ceb4a269ba033ec Mon Sep 17 00:00:00 2001 From: Teus Benschop Date: Sun, 15 Oct 2023 14:19:00 +0200 Subject: [PATCH] Switch to C++20 https://github.com/bibledit/cloud/issues/907 --- Makefile.in | 2 +- config.h | 4 ++-- config.h.in | 4 ++-- configure | 52 +++++++++++++++++++++++++++++++++++++++------------- configure.ac | 2 +- 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/Makefile.in b/Makefile.in index c934e3142..9442e4c65 100644 --- a/Makefile.in +++ b/Makefile.in @@ -942,7 +942,7 @@ GUMBO_CFLAGS = @GUMBO_CFLAGS@ GUMBO_LIBS = @GUMBO_LIBS@ GUNZIP_PATH = @GUNZIP_PATH@ GZIP_PATH = @GZIP_PATH@ -HAVE_CXX17 = @HAVE_CXX17@ +HAVE_CXX20 = @HAVE_CXX20@ ICU_CFLAGS = @ICU_CFLAGS@ ICU_LIBS = @ICU_LIBS@ INSTALL = @INSTALL@ diff --git a/config.h b/config.h index 8df8d6c89..ebbd5cb94 100644 --- a/config.h +++ b/config.h @@ -4,8 +4,8 @@ /* Define whether to compile for Android */ /* #undef HAVE_ANDROID */ -/* define if the compiler supports basic C++17 syntax */ -#define HAVE_CXX17 1 +/* define if the compiler supports basic C++20 syntax */ +#define HAVE_CXX20 1 /* Define whether execinfo.h is present */ #define HAVE_EXECINFO 1 diff --git a/config.h.in b/config.h.in index 5f3831846..950dc7a53 100644 --- a/config.h.in +++ b/config.h.in @@ -3,8 +3,8 @@ /* Define whether to compile for Android */ #undef HAVE_ANDROID -/* define if the compiler supports basic C++17 syntax */ -#undef HAVE_CXX17 +/* define if the compiler supports basic C++20 syntax */ +#undef HAVE_CXX20 /* Define whether execinfo.h is present */ #undef HAVE_EXECINFO diff --git a/configure b/configure index 5cf24f6de..a12300cd8 100755 --- a/configure +++ b/configure @@ -686,7 +686,7 @@ FIND_TAR GUNZIP_PATH GZIP_PATH RANLIB -HAVE_CXX17 +HAVE_CXX20 am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE @@ -5274,7 +5274,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - ax_cxx_compile_alternatives="17 1z" ax_cxx_compile_cxx17_required=true + ax_cxx_compile_alternatives="20" ax_cxx_compile_cxx20_required=true ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -5291,12 +5291,12 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do if test x"$switch" = xMSVC; then switch=-std:c++${alternative} - cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx17_${switch}_MSVC" | $as_tr_sh` + cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx20_${switch}_MSVC" | $as_tr_sh` else - cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh` + cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx20_$switch" | $as_tr_sh` fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5 -printf %s "checking whether $CXX supports C++17 features with $switch... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++20 features with $switch" >&5 +printf %s "checking whether $CXX supports C++20 features with $switch... " >&6; } if eval test \${$cachevar+y} then : printf %s "(cached) " >&6 @@ -6095,6 +6095,32 @@ namespace cxx17 + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 202002L && !defined _MSC_VER + +#error "This is not a C++20 compiler" + +#else + +#include + +namespace cxx20 +{ + +// As C++20 supports feature test macros in the standard, there is no +// immediate need to actually test for feature availability on the +// Autoconf side. + +} // namespace cxx20 + +#endif // __cplusplus < 202002L && !defined _MSC_VER + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO" then : @@ -6128,19 +6154,19 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - if test x$ax_cxx_compile_cxx17_required = xtrue; then + if test x$ax_cxx_compile_cxx20_required = xtrue; then if test x$ac_success = xno; then - as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5 + as_fn_error $? "*** A compiler with support for C++20 language features is required." "$LINENO" 5 fi fi if test x$ac_success = xno; then - HAVE_CXX17=0 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5 -printf "%s\n" "$as_me: No compiler with C++17 support was found" >&6;} + HAVE_CXX20=0 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: No compiler with C++20 support was found" >&5 +printf "%s\n" "$as_me: No compiler with C++20 support was found" >&6;} else - HAVE_CXX17=1 + HAVE_CXX20=1 -printf "%s\n" "#define HAVE_CXX17 1" >>confdefs.h +printf "%s\n" "#define HAVE_CXX20 1" >>confdefs.h fi diff --git a/configure.ac b/configure.ac index cc3ba01f2..2495304f8 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ ac_default_prefix=/usr AC_PROG_CC AC_PROG_CXX AC_LANG([C++]) -AX_CXX_COMPILE_STDCXX(17,[noext],[mandatory]) +AX_CXX_COMPILE_STDCXX(20,[noext],[mandatory]) AC_PROG_RANLIB AC_CONFIG_HEADERS([config.h])