diff --git a/.github/workflows/icu4c.yml b/.github/workflows/icu4c.yml index e9ea2f5e74eb..e085d2ac0a87 100644 --- a/.github/workflows/icu4c.yml +++ b/.github/workflows/icu4c.yml @@ -130,17 +130,17 @@ jobs: make check; # Out of source build with gcc 10, c++14, and extra warnings; executes icuinfo. - gcc-10-stdlib14: + gcc-10-stdlib17: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: ICU4C with gcc 10 and c++14 and extra warnings. + - name: ICU4C with gcc 10 and c++17 and extra warnings. env: PREFIX: /tmp/icu-prefix CC: gcc-10 CXX: g++-10 - CXXFLAGS: -std=c++14 -Wextra + CXXFLAGS: -std=c++17 -Wextra run: | mkdir build; cd build; diff --git a/docs/userguide/icu4c/build.md b/docs/userguide/icu4c/build.md index 16732519f684..9e69727e241a 100644 --- a/docs/userguide/icu4c/build.md +++ b/docs/userguide/icu4c/build.md @@ -200,7 +200,7 @@ The value of `v140` corresponds to the Visual Studio 2015 compiler tool set, whe In order to build the non-UWP projects with Visual Studio 2015 you will need to modify the file called `Build.Windows.ProjectConfiguration.props` to change the value of the `PlatformToolset` property. Note however that Visual Studio 2017 is required for building the UWP projects. -> :point_right: **Note**: Using older versions of the MSVC compiler is generally not recommended due to the improved support for the C++11 standard in newer versions of the compiler. +> :point_right: **Note**: Using older versions of the MSVC compiler is generally not recommended due to the improved support for the C++17 standard in newer versions of the compiler. ### Re-targeting the Windows 10 SDK for the UWP projects diff --git a/icu4c/build_qnx/build-hooks b/icu4c/build_qnx/build-hooks index 93fe62ea7b4f..2a7655b165df 100755 --- a/icu4c/build_qnx/build-hooks +++ b/icu4c/build_qnx/build-hooks @@ -15,7 +15,7 @@ function hook_preconfigure { CFLAGS="$CFLAGS -fPIC" CPPFLAGS="$CPPFLAGS -fPIC" - CXXFLAGS="$CXXFLAGS -std=gnu++11" + CXXFLAGS="$CXXFLAGS -std=gnu++17" else # prefix is the base path where architecture independent files are installed in the target filesystem configure_opts="${configure_opts} --prefix=/" diff --git a/icu4c/source/Doxyfile.in b/icu4c/source/Doxyfile.in index 75bab9365ee8..c3b3f8debcda 100644 --- a/icu4c/source/Doxyfile.in +++ b/icu4c/source/Doxyfile.in @@ -2084,7 +2084,7 @@ PREDEFINED = U_EXPORT2= \ U_DEFINE_LOCAL_OPEN_POINTER()= \ U_IN_DOXYGEN=1 \ U_CHAR16_IS_TYPEDEF=0 \ - U_CPLUSPLUS_VERSION=11 \ + U_CPLUSPLUS_VERSION=17 \ U_WCHAR_IS_UTF16 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this diff --git a/icu4c/source/common/unicode/platform.h b/icu4c/source/common/unicode/platform.h index a997843660c9..6d01d862687b 100644 --- a/icu4c/source/common/unicode/platform.h +++ b/icu4c/source/common/unicode/platform.h @@ -507,6 +507,8 @@ /* Otherwise use the predefined value. */ #elif !defined(__cplusplus) # define U_CPLUSPLUS_VERSION 0 +#elif __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define U_CPLUSPLUS_VERSION 17 #elif __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) # define U_CPLUSPLUS_VERSION 14 #elif __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) diff --git a/icu4c/source/config/mh-solaris b/icu4c/source/config/mh-solaris index a26b468d8789..b6550dcb8e29 100644 --- a/icu4c/source/config/mh-solaris +++ b/icu4c/source/config/mh-solaris @@ -5,8 +5,8 @@ ## Copyright (c) 1999-2010, International Business Machines Corporation and ## others. All Rights Reserved. -## Flags for ICU 59+ -CXXFLAGS += -std=c++11 +## Flags for ICU 75+ +CXXFLAGS += -std=c++17 CFLAGS += -std=c11 ## Flags for position independent code diff --git a/icu4c/source/configure.ac b/icu4c/source/configure.ac index 8e8a6737ded1..d091fde9e77f 100644 --- a/icu4c/source/configure.ac +++ b/icu4c/source/configure.ac @@ -148,8 +148,8 @@ AC_SUBST(ENABLE_RELEASE) # Checks for compilers AC_PROG_CC([clang gcc cc c99 c89 xlc_r xlc cl.exe icc]) -# Make sure that we try clang++ first, which provides C++11 support. -# The g++ compiler is less likely to support C++11. +# Make sure that we try clang++ first, which provides C++17 support. +# The g++ compiler is less likely to support C++17. AC_PROG_CXX([clang++ g++ c++ gpp xlC_r xlC aCC CC cxx cc++ cl.exe icc FCC KCC RCC]) # pkg-config is needed for harfbuzz support @@ -513,17 +513,17 @@ else fi if [[ "$GXX" = yes ]]; then - # if CXXFLAGS does not have a "-std=" setting, set it now to -std=c++11, + # if CXXFLAGS does not have a "-std=" setting, set it now to -std=c++17, # and check that the compiler still works. if ! echo "$CXXFLAGS" | grep '\-std=' >/dev/null 2>&1; then OLD_CXXFLAGS="${CXXFLAGS}" - CXXFLAGS="$CXXFLAGS -std=c++11" - AC_MSG_CHECKING([[if we have a C++11 compiler]]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[cxx11_okay=yes],[cxx11_okay=no]) - AC_MSG_RESULT($cxx11_okay) - if [[ $cxx11_okay = yes ]]; then - AC_MSG_NOTICE([Adding CXXFLAGS option -std=c++11]) - UCONFIG_CXXFLAGS="${UCONFIG_CXXFLAGS} -std=c++11" + CXXFLAGS="$CXXFLAGS -std=c++17" + AC_MSG_CHECKING([[if we have a C++17 compiler]]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[cxx17_okay=yes],[cxx17_okay=no]) + AC_MSG_RESULT($cxx17_okay) + if [[ $cxx17_okay = yes ]]; then + AC_MSG_NOTICE([Adding CXXFLAGS option -std=c++17]) + UCONFIG_CXXFLAGS="${UCONFIG_CXXFLAGS} -std=c++17" else CXXFLAGS="$OLD_CXXFLAGS" fi diff --git a/icu4c/source/test/depstest/dependencies.txt b/icu4c/source/test/depstest/dependencies.txt index 1486b779f767..8474348b0374 100644 --- a/icu4c/source/test/depstest/dependencies.txt +++ b/icu4c/source/test/depstest/dependencies.txt @@ -125,6 +125,7 @@ group: cplusplus # even when no code actually uses it. # ICU must not _use_ the global operator delete. "operator delete(void*)" + "operator delete(void*, unsigned long)" # ICU also must not use the global operator new. # "operator new[](unsigned long)" diff --git a/icu4c/source/test/hdrtst/testinternalheaders.sh b/icu4c/source/test/hdrtst/testinternalheaders.sh index eaad8b10d553..a6e63b595a88 100755 --- a/icu4c/source/test/hdrtst/testinternalheaders.sh +++ b/icu4c/source/test/hdrtst/testinternalheaders.sh @@ -17,7 +17,7 @@ for file in `ls common/*.h`; do echo $file echo '#include "'$file'"' > ht_temp.cpp ; echo 'void noop() {}' >> ht_temp.cpp ; - $CXX -c -std=c++11 -I common -DU_COMMON_IMPLEMENTATION -O0 ht_temp.cpp ; + $CXX -c -std=c++17 -I common -DU_COMMON_IMPLEMENTATION -O0 ht_temp.cpp ; if [ $? != 0 ] ; then ERROR_EXIT=1 fi @@ -27,7 +27,7 @@ for file in `ls i18n/*.h`; do echo $file echo '#include "'$file'"' > ht_temp.cpp ; echo 'void noop() {}' >> ht_temp.cpp ; - $CXX -c -std=c++11 -I common -I i18n -DU_I18N_IMPLEMENTATION -O0 ht_temp.cpp ; + $CXX -c -std=c++17 -I common -I i18n -DU_I18N_IMPLEMENTATION -O0 ht_temp.cpp ; if [ $? != 0 ] ; then ERROR_EXIT=1 fi @@ -37,7 +37,7 @@ for file in `ls io/*.h`; do echo $file echo '#include "'$file'"' > ht_temp.cpp ; echo 'void noop() {}' >> ht_temp.cpp ; - $CXX -c -std=c++11 -I common -I i18n -I io -DU_IO_IMPLEMENTATION -O0 ht_temp.cpp ; + $CXX -c -std=c++17 -I common -I i18n -I io -DU_IO_IMPLEMENTATION -O0 ht_temp.cpp ; if [ $? != 0 ] ; then ERROR_EXIT=1 fi @@ -61,7 +61,7 @@ for file in `ls tools/toolutil/*.h`; do echo $file echo '#include "'$file'"' > ht_temp.cpp ; echo 'void noop() {}' >> ht_temp.cpp ; - $CXX -c -std=c++11 -I common -I i18n -I io -I tools/toolutil -O0 ht_temp.cpp ; + $CXX -c -std=c++17 -I common -I i18n -I io -I tools/toolutil -O0 ht_temp.cpp ; if [ $? != 0 ] ; then ERROR_EXIT=1 fi @@ -78,7 +78,7 @@ for tool in escapesrc genccode gencmn gencolusb gennorm2 genren gentest icupkg i echo $file echo '#include "'$file'"' > ht_temp.cpp ; echo 'void noop() {}' >> ht_temp.cpp ; - $CXX -c -std=c++11 -I common -I i18n -I io -I tools/toolutil -I tools/$tool -O0 ht_temp.cpp ; + $CXX -c -std=c++17 -I common -I i18n -I io -I tools/toolutil -I tools/$tool -O0 ht_temp.cpp ; if [ $? != 0 ] ; then ERROR_EXIT=1 fi @@ -91,7 +91,7 @@ for file in `ls tools/ctestfw/unicode/*.h`; do echo $file echo '#include "'$file'"' > ht_temp.cpp ; echo 'void noop() {}' >> ht_temp.cpp ; - $CXX -c -std=c++11 -I common -I i18n -I io -I tools/toolutil -I tools/ctestfw -O0 ht_temp.cpp ; + $CXX -c -std=c++17 -I common -I i18n -I io -I tools/toolutil -I tools/ctestfw -O0 ht_temp.cpp ; if [ $? != 0 ] ; then ERROR_EXIT=1 fi @@ -113,7 +113,7 @@ for test in intltest iotest testmap thaitest fuzzer; do echo $file echo '#include "'$file'"' > ht_temp.cpp ; echo 'void noop() {}' >> ht_temp.cpp ; - $CXX -c -std=c++11 -I common -I i18n -I io -I tools/toolutil -I tools/ctestfw -I test/$test -O0 ht_temp.cpp ; + $CXX -c -std=c++17 -I common -I i18n -I io -I tools/toolutil -I tools/ctestfw -I test/$test -O0 ht_temp.cpp ; if [ $? != 0 ] ; then ERROR_EXIT=1 fi diff --git a/tools/unicode/c/CMakeLists.txt b/tools/unicode/c/CMakeLists.txt index 9a924ddbbb32..111ae4390ac9 100644 --- a/tools/unicode/c/CMakeLists.txt +++ b/tools/unicode/c/CMakeLists.txt @@ -7,7 +7,7 @@ # created by: Markus W. Scherer cmake_minimum_required(VERSION 2.6) project(ICU_UNI_TOOLS) -set(CMAKE_CXX_FLAGS "-std=c++11 -fsanitize=bounds") +set(CMAKE_CXX_FLAGS "-std=c++17 -fsanitize=bounds") set(CMAKE_LD_FLAGS "-fsanitize=bounds") # This requires an icudefs.txt file with contents like the following: # Location (--prefix) of where ICU was installed. diff --git a/tools/unicode/c/genregexcasing/Makefile b/tools/unicode/c/genregexcasing/Makefile index 105cb9e13eb6..c9238cce2d79 100644 --- a/tools/unicode/c/genregexcasing/Makefile +++ b/tools/unicode/c/genregexcasing/Makefile @@ -13,4 +13,4 @@ data: genregexcasing LD_LIBRARY_PATH=$(ICU_BUILD)/lib:$(ICU_BUILD)/stubdata ICU_DATA=$(ICU_BUILD)/data/out ./genregexcasing genregexcasing: genregexcasing.cpp - clang++ genregexcasing.cpp -std=c++0x -g -I $(ICU_HOME)/common -I $(ICU_HOME)/i18n -I $(ICU_HOME)/io -L$(ICU_BUILD)/lib -L$(ICU_BUILD)/stubdata -licuuc -licui18n -licudata -o genregexcasing + clang++ genregexcasing.cpp -std=c++17 -g -I $(ICU_HOME)/common -I $(ICU_HOME)/i18n -I $(ICU_HOME)/io -L$(ICU_BUILD)/lib -L$(ICU_BUILD)/stubdata -licuuc -licui18n -licudata -o genregexcasing