Skip to content

Commit

Permalink
Require C++23.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilx committed Sep 22, 2024
1 parent 57292fb commit 6ca8dba
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 29 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ set (CMAKE_POSITION_INDEPENDENT_CODE ON)

enable_language (CXX)
if (MSVC)
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_STANDARD 23)
if (CMAKE_VS_PLATFORM_NAME MATCHES "ARM")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif ()
else ()
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_STANDARD 23)
endif ()
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS ON)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GREP = @GREP@
HAVE_CXX20 = @HAVE_CXX20@
HAVE_CXX23 = @HAVE_CXX23@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
Expand Down
124 changes: 101 additions & 23 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ USE_LOG4CPLUS_EXPORT_SYMBOLS_REGEX_TRUE
LOG4CPLUS_AIX_XLC_LDFLAGS
GREP
SED
HAVE_CXX20
HAVE_CXX23
CXXCPP
am__fastdepCXX_FALSE
am__fastdepCXX_TRUE
Expand Down Expand Up @@ -6684,17 +6684,17 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu



ax_cxx_compile_alternatives="20" ax_cxx_compile_cxx20_required=true
ax_cxx_compile_alternatives="23 2b" ax_cxx_compile_cxx23_required=true
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
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
ac_success=no

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++20 features by default" >&5
printf %s "checking whether $CXX supports C++20 features by default... " >&6; }
if test ${ax_cv_cxx_compile_cxx20+y}
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++23 features by default" >&5
printf %s "checking whether $CXX supports C++23 features by default... " >&6; }
if test ${ax_cv_cxx_compile_cxx23+y}
then :
printf %s "(cached) " >&6
else case e in #(
Expand Down Expand Up @@ -7516,29 +7516,55 @@ namespace cxx20




#ifndef __cplusplus

#error "This is not a C++ compiler"

#elif __cplusplus < 202302L && !defined _MSC_VER

#error "This is not a C++23 compiler"

#else

#include <version>

namespace cxx23
{

// As C++23 supports feature test macros in the standard, there is no
// immediate need to actually test for feature availability on the
// Autoconf side.

} // namespace cxx23

#endif // __cplusplus < 202302L && !defined _MSC_VER



_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :
ax_cv_cxx_compile_cxx20=yes
ax_cv_cxx_compile_cxx23=yes
else case e in #(
e) ax_cv_cxx_compile_cxx20=no ;;
e) ax_cv_cxx_compile_cxx23=no ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx20" >&5
printf "%s\n" "$ax_cv_cxx_compile_cxx20" >&6; }
if test x$ax_cv_cxx_compile_cxx20 = xyes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx23" >&5
printf "%s\n" "$ax_cv_cxx_compile_cxx23" >&6; }
if test x$ax_cv_cxx_compile_cxx23 = xyes; then
ac_success=yes
fi

if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
switch="-std=gnu++${alternative}"
cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx20_$switch" | sed "$as_sed_sh"`
{ 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; }
cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx23_$switch" | sed "$as_sed_sh"`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++23 features with $switch" >&5
printf %s "checking whether $CXX supports C++23 features with $switch... " >&6; }
if eval test \${$cachevar+y}
then :
printf %s "(cached) " >&6
Expand Down Expand Up @@ -8363,6 +8389,32 @@ namespace cxx20




#ifndef __cplusplus

#error "This is not a C++ compiler"

#elif __cplusplus < 202302L && !defined _MSC_VER

#error "This is not a C++23 compiler"

#else

#include <version>

namespace cxx23
{

// As C++23 supports feature test macros in the standard, there is no
// immediate need to actually test for feature availability on the
// Autoconf side.

} // namespace cxx23

#endif // __cplusplus < 202302L && !defined _MSC_VER



_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :
Expand Down Expand Up @@ -8392,9 +8444,9 @@ printf "%s\n" "$ac_res" >&6; }
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx20_$switch" | sed "$as_sed_sh"`
{ 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; }
cachevar=`printf "%s\n" "ax_cv_cxx_compile_cxx23_$switch" | sed "$as_sed_sh"`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++23 features with $switch" >&5
printf %s "checking whether $CXX supports C++23 features with $switch... " >&6; }
if eval test \${$cachevar+y}
then :
printf %s "(cached) " >&6
Expand Down Expand Up @@ -9219,6 +9271,32 @@ namespace cxx20




#ifndef __cplusplus

#error "This is not a C++ compiler"

#elif __cplusplus < 202302L && !defined _MSC_VER

#error "This is not a C++23 compiler"

#else

#include <version>

namespace cxx23
{

// As C++23 supports feature test macros in the standard, there is no
// immediate need to actually test for feature availability on the
// Autoconf side.

} // namespace cxx23

#endif // __cplusplus < 202302L && !defined _MSC_VER



_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :
Expand Down Expand Up @@ -9254,19 +9332,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_cxx20_required = xtrue; then
if test x$ax_cxx_compile_cxx23_required = xtrue; then
if test x$ac_success = xno; then
as_fn_error $? "*** A compiler with support for C++20 language features is required." "$LINENO" 5
as_fn_error $? "*** A compiler with support for C++23 language features is required." "$LINENO" 5
fi
fi
if test x$ac_success = xno; then
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;}
HAVE_CXX23=0
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: No compiler with C++23 support was found" >&5
printf "%s\n" "$as_me: No compiler with C++23 support was found" >&6;}
else
HAVE_CXX20=1
HAVE_CXX23=1

printf "%s\n" "#define HAVE_CXX20 1" >>confdefs.h
printf "%s\n" "#define HAVE_CXX23 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 @@ -179,7 +179,7 @@ AC_PROG_CXX
AC_PROG_CXXCPP
AC_LANG([C++])

AX_CXX_COMPILE_STDCXX([20],[],[mandatory])
AX_CXX_COMPILE_STDCXX([23],[],[mandatory])

AS_VAR_APPEND([CPPFLAGS], [" -D_GNU_SOURCE=1"])

Expand Down
2 changes: 1 addition & 1 deletion include/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GREP = @GREP@
HAVE_CXX20 = @HAVE_CXX20@
HAVE_CXX23 = @HAVE_CXX23@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
Expand Down
43 changes: 42 additions & 1 deletion m4/ax_cxx_compile_stdcxx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[$1], [20], [ax_cxx_compile_alternatives="20"],
[$1], [20], [ax_cxx_compile_alternatives="20 2a"],
[$1], [23], [ax_cxx_compile_alternatives="23 2b"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
Expand Down Expand Up @@ -177,6 +178,16 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
)

dnl Test body for checking C++23 support

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_23],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
_AX_CXX_COMPILE_STDCXX_testbody_new_in_23
)


dnl Tests for new features in C++11

Expand Down Expand Up @@ -1007,3 +1018,33 @@ namespace cxx20
#endif // __cplusplus < 202002L && !defined _MSC_VER
]])


dnl Tests for new features in C++23

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_23], [[
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 202302L && !defined _MSC_VER
#error "This is not a C++23 compiler"
#else
#include <version>
namespace cxx23
{
// As C++23 supports feature test macros in the standard, there is no
// immediate need to actually test for feature availability on the
// Autoconf side.
} // namespace cxx23
#endif // __cplusplus < 202302L && !defined _MSC_VER
]])

0 comments on commit 6ca8dba

Please sign in to comment.