Skip to content

Commit

Permalink
Switch to C++20
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Oct 15, 2023
1 parent 529bccb commit d846c37
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand Down
4 changes: 2 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 39 additions & 13 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ FIND_TAR
GUNZIP_PATH
GZIP_PATH
RANLIB
HAVE_CXX17
HAVE_CXX20
am__fastdepCXX_FALSE
am__fastdepCXX_TRUE
CXXDEPMODE
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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 <version>
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 :
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down

0 comments on commit d846c37

Please sign in to comment.