Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU-21107 Update ICU4C minimum standard version from C++11 to C++17 #2737

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/icu4c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion docs/userguide/icu4c/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion icu4c/build_qnx/build-hooks
Original file line number Diff line number Diff line change
Expand Up @@ -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=/"
Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions icu4c/source/common/unicode/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/config/mh-solaris
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions icu4c/source/configure
Original file line number Diff line number Diff line change
Expand Up @@ -3515,8 +3515,8 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

# 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_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
Expand Down Expand Up @@ -6128,13 +6128,13 @@ $as_echo "no" >&6; }
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"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have a C++11 compiler" >&5
$as_echo_n "checking if we have a C++11 compiler... " >&6; }
CXXFLAGS="$CXXFLAGS -std=c++17"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have a C++17 compiler" >&5
$as_echo_n "checking if we have a C++17 compiler... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

Expand All @@ -6147,17 +6147,17 @@ main ()
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
cxx11_okay=yes
cxx17_okay=yes
else
cxx11_okay=no
cxx17_okay=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cxx11_okay" >&5
$as_echo "$cxx11_okay" >&6; }
if [ $cxx11_okay = yes ]; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Adding CXXFLAGS option -std=c++11" >&5
$as_echo "$as_me: Adding CXXFLAGS option -std=c++11" >&6;}
UCONFIG_CXXFLAGS="${UCONFIG_CXXFLAGS} -std=c++11"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cxx17_okay" >&5
$as_echo "$cxx17_okay" >&6; }
if [ $cxx17_okay = yes ]; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Adding CXXFLAGS option -std=c++17" >&5
$as_echo "$as_me: Adding CXXFLAGS option -std=c++17" >&6;}
UCONFIG_CXXFLAGS="${UCONFIG_CXXFLAGS} -std=c++17"
else
CXXFLAGS="$OLD_CXXFLAGS"
fi
Expand Down
20 changes: 10 additions & 10 deletions icu4c/source/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions icu4c/source/test/depstest/dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand Down
14 changes: 7 additions & 7 deletions icu4c/source/test/hdrtst/testinternalheaders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/unicode/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tools/unicode/c/genregexcasing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading