mirror of
https://github.com/postgres/postgres.git
synced 2025-10-15 05:46:52 +03:00
Raise C requirement to C11
This changes configure and meson.build to require at least C11,
instead of the previous C99. The installation documentation is
updated accordingly.
configure.ac previously used AC_PROG_CC_C99 to activate C99. But
there is no AC_PROG_CC_C11 in Autoconf 2.69, because it's too
old. (Also, post-2.69, the AC_PROG_CC_Cnn macros were deprecated and
AC_PROG_CC activates the last supported C mode.) We could update the
required Autoconf version, but that might be a separate project that
no one wants to undertake at the moment. Instead, we open-code the
test for C11 using some inspiration from later Autoconf versions. But
instead of writing an elaborate test program, we keep it simple and
just check __STDC_VERSION__, which should be good enough in practice.
In meson.build, we update the existing C99 test to C11, but again we
just check for __STDC_VERSION__.
This also removes the separate option for the conforming preprocessor
on MSVC, added by commit 8fd9bb1d96
, since that is activated
automatically in C11 mode.
Note, we don't use the "official" way to set the C standard in Meson
using the c_std project option, because that is impossible to use
correctly (see <https://github.com/mesonbuild/meson/issues/14717>).
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/01a69441-af54-4822-891b-ca28e05b215a@eisentraut.org
This commit is contained in:
29
configure.ac
29
configure.ac
@@ -364,14 +364,33 @@ pgac_cc_list="gcc cc"
|
||||
pgac_cxx_list="g++ c++"
|
||||
|
||||
AC_PROG_CC([$pgac_cc_list])
|
||||
AC_PROG_CC_C99()
|
||||
|
||||
# Error out if the compiler does not support C99, as the codebase
|
||||
# relies on that.
|
||||
if test "$ac_cv_prog_cc_c99" = no; then
|
||||
AC_MSG_ERROR([C compiler "$CC" does not support C99])
|
||||
# Detect option needed for C11
|
||||
# loosely modeled after code in later Autoconf versions
|
||||
AC_MSG_CHECKING([for $CC option to accept ISO C11])
|
||||
AC_CACHE_VAL([pgac_cv_prog_cc_c11],
|
||||
[pgac_cv_prog_cc_c11=no
|
||||
pgac_save_CC=$CC
|
||||
for pgac_arg in '' '-std=gnu11' '-std=c11'; do
|
||||
CC="$pgac_save_CC $pgac_arg"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
|
||||
# error "Compiler does not advertise C11 conformance"
|
||||
#endif]])], [[pgac_cv_prog_cc_c11=$pgac_arg]])
|
||||
test x"$pgac_cv_prog_cc_c11" != x"no" && break
|
||||
done
|
||||
CC=$pgac_save_CC])
|
||||
|
||||
if test x"$pgac_cv_prog_cc_c11" = x"no"; then
|
||||
AC_MSG_RESULT([unsupported])
|
||||
AC_MSG_ERROR([C compiler "$CC" does not support C11])
|
||||
elif test x"$pgac_cv_prog_cc_c11" = x""; then
|
||||
AC_MSG_RESULT([none needed])
|
||||
else
|
||||
AC_MSG_RESULT([$pgac_cv_prog_cc_c11])
|
||||
CC="$CC $pgac_cv_prog_cc_c11"
|
||||
fi
|
||||
|
||||
|
||||
AC_PROG_CXX([$pgac_cxx_list])
|
||||
|
||||
# Check if it's Intel's compiler, which (usually) pretends to be gcc,
|
||||
|
Reference in New Issue
Block a user