ICU-21107 Update ICU4C minimum standard version from C99 to C11.

This commit is contained in:
Fredrik Roubert 2023-12-20 20:32:36 +09:00 committed by Fredrik Roubert
parent fc6e282d98
commit 45d351ca4e
3 changed files with 17 additions and 13 deletions

View file

@ -22,7 +22,7 @@ License & terms of use: http://www.unicode.org/copyright.html
## Recommended Build Options
Depending on the platform and the type of installation, we recommend a small number of modifications and build options. Note that C99 compatibility is now required.
Depending on the platform and the type of installation, we recommend a small number of modifications and build options. Note that C11 compatibility is now required.
* **Namespace (ICU 61 and later):** Since ICU 61, call sites need to qualify ICU types explicitly, for example `icu::UnicodeString`, or do `using icu::UnicodeString;` where appropriate. If your code relies on the "using namespace icu;" that used to be in `unicode/uversion.h`, then you need to update your code.
You could temporarily (until you have more time to update your code) revert to the default "using" via `-DU_USING_ICU_NAMESPACE=1` or by modifying `unicode/uversion.h`:
@ -339,7 +339,7 @@ Here are the steps to build ICU:
gmake
```
(or just `make` if GNU make is the default make on your platform) to compile the libraries and all the data files. The proper name of the GNU make command is printed at the end of the configuration run, as in `"You must use gmake to compile ICU"`.
Note that the compilation command output may be simplified on your platform. If this is the case, you will see just: `gcc ... stubdata.c` rather than `gcc -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 -D_REENTRANT -I../common -DU_ATTRIBUTE_DEPRECATED= -O2 -Wall -std=c99 -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -c -DPIC -fPIC -o stubdata.o stubdata.c`
Note that the compilation command output may be simplified on your platform. If this is the case, you will see just: `gcc ... stubdata.c` rather than `gcc -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 -D_REENTRANT -I../common -DU_ATTRIBUTE_DEPRECATED= -O2 -Wall -std=c11 -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -c -DPIC -fPIC -o stubdata.o stubdata.c`
If you need to see the whole compilation line, use `gmake VERBOSE=1`. The full compilation line will print if an error occurs.
1. Optionally,
```

View file

@ -463,17 +463,6 @@ AC_DEFUN([AC_CHECK_STRICT_COMPILE],
then
if test "$GCC" = yes
then
case "${host}" in
*-*-solaris*)
# Don't use -std=c11 on Solaris because of timezone check fails
;;
*)
# Do not use -ansi. It limits us to C90, and it breaks some platforms.
# We use -std=c11 to disable the gnu99 defaults and its associated warnings
CFLAGS="$CFLAGS -std=c11"
;;
esac
CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
else
case "${host}" in

View file

@ -175,6 +175,21 @@ if test "$GCC" = yes; then
CXXFLAGS="$CXXFLAGS -O2"
fi
fi
# if CFLAGS does not have a "-std=" setting, set it now to -std=c11,
# and check that the compiler still works.
if ! echo "$CFLAGS" | grep '\-std=' >/dev/null 2>&1; then
OLD_CFLAGS="${CFLAGS}"
CFLAGS="$CFLAGS -std=c11"
AC_MSG_CHECKING([[if we have a C11 compiler]])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[c11_okay=yes],[c11_okay=no])
AC_MSG_RESULT($c11_okay)
if [[ $c11_okay = yes ]]; then
AC_MSG_NOTICE([Adding CFLAGS option -std=c11])
UCONFIG_CFLAGS="${UCONFIG_CFLAGS} -std=c11"
else
CFLAGS="$OLD_CFLAGS"
fi
fi
fi
AC_PROG_CPP