Skip to content

Commit 9206863

Browse files
committed
Require C++23
1 parent 10e27fd commit 9206863

4 files changed

Lines changed: 78 additions & 25 deletions

File tree

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Requirements
3030
------------
3131

3232
The libngtcp2 C library itself does not depend on any external
33-
libraries. The example client, and server are written in C++20, and
34-
should compile with the modern C++ compilers (e.g., clang >= 11.0, or
35-
gcc >= 11.0).
33+
libraries. The example client, and server are written in C++23, and
34+
should compile with the modern C++ compilers (e.g., clang >= 19, or
35+
gcc >= 15).
3636

3737
The following packages are required to configure the build system:
3838

configure.ac

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ AC_PROG_MKDIR_P
190190

191191
PKG_PROG_PKG_CONFIG([0.20])
192192

193-
AX_CXX_COMPILE_STDCXX([20], [], [optional])
193+
AX_CXX_COMPILE_STDCXX([23], [], [optional])
194194

195195
case "${build}" in
196196
*-apple-darwin*)
@@ -540,16 +540,16 @@ if test "x${lib_only}" = "xno"; then
540540
fi
541541

542542
if test "x${lib_only}" = "xno" &&
543-
test "x${HAVE_CXX20}" != "x1"; then
544-
AC_MSG_WARN([C++ compiler is not capable of C++20. Examples will not be built.])
543+
test "x${HAVE_CXX23}" != "x1"; then
544+
AC_MSG_WARN([C++ compiler is not capable of C++23. Examples will not be built.])
545545
fi
546546

547547
enable_examples=no
548548
if test "x${lib_only}" = "xno" &&
549549
test "x${have_libnghttp3}" = "xyes" &&
550550
test "x${have_crypto}" = "xyes" &&
551551
test "x${have_libev}" = "xyes" &&
552-
test "x${HAVE_CXX20}" = "x1"; then
552+
test "x${HAVE_CXX23}" = "x1"; then
553553
enable_examples=yes
554554
fi
555555

examples/util_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <limits>
2828
#include <array>
29+
#include <iterator>
2930

3031
#include "util.h"
3132

m4/ax_cxx_compile_stdcxx.m4

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#
1111
# Check for baseline language coverage in the compiler for the specified
1212
# version of the C++ standard. If necessary, add switches to CXX and
13-
# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for
14-
# the respective C++ standard version.
13+
# CXXCPP to enable support. VERSION may be '11', '14', '17', '20', or
14+
# '23' for the respective C++ standard version.
1515
#
1616
# The second argument, if specified, indicates whether you insist on an
1717
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
@@ -36,14 +36,15 @@
3636
# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
3737
# Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
3838
# Copyright (c) 2020 Jason Merrill <jason@redhat.com>
39-
# Copyright (c) 2021 Jörn Heusipp <osmanx@problemloesungsmaschine.de>
39+
# Copyright (c) 2021, 2024 Jörn Heusipp <osmanx@problemloesungsmaschine.de>
40+
# Copyright (c) 2015, 2022, 2023, 2024 Olly Betts
4041
#
4142
# Copying and distribution of this file, with or without modification, are
4243
# permitted in any medium without royalty provided the copyright notice
4344
# and this notice are preserved. This file is offered as-is, without any
4445
# warranty.
4546

46-
#serial 18
47+
#serial 25
4748

4849
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
4950
dnl (serial version number 13).
@@ -53,6 +54,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
5354
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
5455
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
5556
[$1], [20], [ax_cxx_compile_alternatives="20"],
57+
[$1], [23], [ax_cxx_compile_alternatives="23"],
5658
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
5759
m4_if([$2], [], [],
5860
[$2], [ext], [],
@@ -159,31 +161,41 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
159161
dnl Test body for checking C++11 support
160162

161163
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
162-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
164+
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11]
163165
)
164166

165167
dnl Test body for checking C++14 support
166168

167169
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
168-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
169-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
170+
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
171+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14]
170172
)
171173

172174
dnl Test body for checking C++17 support
173175

174176
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
175-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
176-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
177-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
177+
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
178+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
179+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17]
178180
)
179181

180182
dnl Test body for checking C++20 support
181183

182184
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
183-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
184-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
185-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
186-
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
185+
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
186+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
187+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
188+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20]
189+
)
190+
191+
dnl Test body for checking C++23 support
192+
193+
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_23],
194+
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
195+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
196+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
197+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
198+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_23]
187199
)
188200

189201

@@ -201,7 +213,17 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
201213
// MSVC always sets __cplusplus to 199711L in older versions; newer versions
202214
// only set it correctly if /Zc:__cplusplus is specified as well as a
203215
// /std:c++NN switch:
216+
//
204217
// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
218+
//
219+
// The value __cplusplus ought to have is available in _MSVC_LANG since
220+
// Visual Studio 2015 Update 3:
221+
//
222+
// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
223+
//
224+
// This was also the first MSVC version to support C++14 so we can't use the
225+
// value of either __cplusplus or _MSVC_LANG to quickly rule out MSVC having
226+
// C++11 or C++14 support, but we can check _MSVC_LANG for C++17 and later.
205227
#elif __cplusplus < 201103L && !defined _MSC_VER
206228
207229
#error "This is not a C++11 compiler"
@@ -617,7 +639,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
617639
618640
#error "This is not a C++ compiler"
619641
620-
#elif __cplusplus < 201703L && !defined _MSC_VER
642+
#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 201703L
621643
622644
#error "This is not a C++17 compiler"
623645
@@ -983,7 +1005,7 @@ namespace cxx17
9831005
9841006
} // namespace cxx17
9851007
986-
#endif // __cplusplus < 201703L && !defined _MSC_VER
1008+
#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 201703L
9871009
9881010
]])
9891011

@@ -996,7 +1018,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
9961018
9971019
#error "This is not a C++ compiler"
9981020
999-
#elif __cplusplus < 202002L && !defined _MSC_VER
1021+
#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202002L
10001022
10011023
#error "This is not a C++20 compiler"
10021024
@@ -1013,6 +1035,36 @@ namespace cxx20
10131035
10141036
} // namespace cxx20
10151037
1016-
#endif // __cplusplus < 202002L && !defined _MSC_VER
1038+
#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202002L
1039+
1040+
]])
1041+
1042+
1043+
dnl Tests for new features in C++23
1044+
1045+
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_23], [[
1046+
1047+
#ifndef __cplusplus
1048+
1049+
#error "This is not a C++ compiler"
1050+
1051+
#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202302L
1052+
1053+
#error "This is not a C++23 compiler"
1054+
1055+
#else
1056+
1057+
#include <version>
1058+
1059+
namespace cxx23
1060+
{
1061+
1062+
// As C++23 supports feature test macros in the standard, there is no
1063+
// immediate need to actually test for feature availability on the
1064+
// Autoconf side.
1065+
1066+
} // namespace cxx23
1067+
1068+
#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202302L
10171069
10181070
]])

0 commit comments

Comments
 (0)