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

Commit5b40ce7

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 parent0536f8e commit5b40ce7

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
@@ -4396,6 +4396,78 @@ else
43964396
fi
43974397
fi
43984398

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

‎configure.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,26 @@ else
414414
fi
415415
fi
416416

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp