Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit70cf253

Browse files
committed
If a C23 compiler is detected, try asking for C17.
Branches before 16 can't be compiled with a C23 compiler (seedeprecation warnings silenced by commitf9a56e7, and non-back-patchablechanges made in 16 by commit1c27d16). Test __STDC_VERSION__, and ifit's above C17 then try appending -std=gnu17. The test is done with theuser's CFLAGS, so an acceptable language version can also be configuredmanually that way.This is done in branches 15 and older, back to 9.2, per policy ofkeeping them buildable with modern tools.Discussion:https://postgr.es/m/87o72eo9iu.fsf%40gentoo.org
1 parent12c8faa commit70cf253

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

‎configure

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4411,6 +4411,78 @@ else
44114411
fi
44124412
fi
44134413

4414+
# We use C constructs that became invalid in C23. Check if the compiler
4415+
# reports a standard higher than C17, with the flags selected above (so the
4416+
# user can control the language level explicitly to avoid the gcc/clang-only
4417+
# fallback logic below if preferred).
4418+
{$as_echo"$as_me:${as_lineno-$LINENO}: checking whether$CC reports a C standard higher than ISO C17">&5
4419+
$as_echo_n"checking whether$CC reports a C standard higher than ISO C17...">&6; }
4420+
cat confdefs.h -<<_ACEOF >conftest.$ac_ext
4421+
/* end confdefs.h. */
4422+
4423+
int
4424+
main ()
4425+
{
4426+
#if __STDC_VERSION__ > 201710L
4427+
choke me
4428+
#endif
4429+
;
4430+
return 0;
4431+
}
4432+
_ACEOF
4433+
if ac_fn_c_try_compile"$LINENO";then:
4434+
POSTC17=no
4435+
else
4436+
POSTC17=yes
4437+
fi
4438+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4439+
{$as_echo"$as_me:${as_lineno-$LINENO}: result:${POSTC17}">&5
4440+
$as_echo"${POSTC17}">&6; }
4441+
4442+
# If a too recent standard was detected with the user's CFLAGS, try asking for
4443+
# C17 with GNU extensions explicitly.
4444+
iftest"$POSTC17" = yes;then
4445+
old_CFLAGS="$CFLAGS"
4446+
{$as_echo"$as_me:${as_lineno-$LINENO}: checking whether$CC supports -std=gnu17">&5
4447+
$as_echo_n"checking whether$CC supports -std=gnu17...">&6; }
4448+
if${pgac_cv_prog_cc_cflags__std_gnu17+:}false;then:
4449+
$as_echo_n"(cached)">&6
4450+
else
4451+
pgac_save_CFLAGS=$CFLAGS
4452+
CFLAGS="$pgac_save_CFLAGS -std=gnu17"
4453+
ac_save_c_werror_flag=$ac_c_werror_flag
4454+
ac_c_werror_flag=yes
4455+
cat confdefs.h -<<_ACEOF >conftest.$ac_ext
4456+
/* end confdefs.h. */
4457+
4458+
int
4459+
main ()
4460+
{
4461+
4462+
;
4463+
return 0;
4464+
}
4465+
_ACEOF
4466+
if ac_fn_c_try_compile"$LINENO";then:
4467+
pgac_cv_prog_cc_cflags__std_gnu17=yes
4468+
else
4469+
pgac_cv_prog_cc_cflags__std_gnu17=no
4470+
fi
4471+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4472+
ac_c_werror_flag=$ac_save_c_werror_flag
4473+
CFLAGS="$pgac_save_CFLAGS"
4474+
fi
4475+
{$as_echo"$as_me:${as_lineno-$LINENO}: result:$pgac_cv_prog_cc_cflags__std_gnu17">&5
4476+
$as_echo"$pgac_cv_prog_cc_cflags__std_gnu17">&6; }
4477+
iftest x"$pgac_cv_prog_cc_cflags__std_gnu17" = x"yes";then
4478+
CFLAGS="$CFLAGS -std=gnu17"
4479+
fi
4480+
4481+
iftest"$CFLAGS" ="$old_CFLAGS";then
4482+
as_fn_error$?"cannot proceed""$LINENO" 5
4483+
fi
4484+
fi
4485+
44144486
# CFLAGS we determined above will be added back at the end
44154487
user_CFLAGS=$CFLAGS
44164488
CFLAGS=""

‎configure.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,26 @@ else
425425
fi
426426
fi
427427

428+
# We use C constructs that became invalid in C23. Check if the compiler
429+
# reports a standard higher than C17, with the flags selected above (so the
430+
# user can control the language level explicitly to avoid the gcc/clang-only
431+
# fallback logic below if preferred).
432+
AC_MSG_CHECKING([whether $CC reports a C standard higher than ISO C17])
433+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@if __STDC_VERSION__ > 201710L
434+
choke me
435+
@%:@endif])], [POSTC17=no], [POSTC17=yes])
436+
AC_MSG_RESULT(${POSTC17})
437+
438+
# If a too recent standard was detected with the user's CFLAGS, try asking for
439+
# C17 with GNU extensions explicitly.
440+
if test "$POSTC17" = yes; then
441+
old_CFLAGS="$CFLAGS"
442+
PGAC_PROG_CC_CFLAGS_OPT([-std=gnu17])
443+
if test "$CFLAGS" = "$old_CFLAGS"; then
444+
AC_MSG_ERROR([cannot proceed])
445+
fi
446+
fi
447+
428448
# CFLAGS we determined above will be added back at the end
429449
user_CFLAGS=$CFLAGS
430450
CFLAGS=""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp