config.guess: Avoid implicit int in definitions of main.

Implicit ‘int’ (e.g. ‘extern foo();’ meaning the same thing as
‘extern int foo();’) was dropped from the C standard in its 1999
edition.  Twenty-five years later, free C compilers are finally
starting to make this an error by default, so let’s not use it
anymore in config.guess probe programs.

(Note: As of this writing, GCC 14 and Clang 16 are both more lenient
for ‘main() { … }’ specifically than for other uses of implicit int.
Still, the writing is clearly on the wall.)

We continue to use ‘int main() { … }’, instead of ‘int main(void) { … }’,
because these programs may be compiled by truly ancient compilers that
do not recognize the keyword ‘void’.  This leaves open the possibility
of a compiler that errors by default on an empty argument list in a
function definition, which, prior to the 2024 C standard, is technically
still an “old-style” function definition; but we can worry about that
if and when it comes up.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Co-authored-by: Zack Weinberg <zack@owlfolio.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
Petr Vorel 2024-05-13 16:55:28 -04:00 committed by Dmitry V. Levin
parent 2734c47247
commit 9d1d9d5260
2 changed files with 7 additions and 4 deletions

9
config.guess vendored
View File

@ -4,7 +4,7 @@
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2024-01-01'
timestamp='2024-04-03'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -634,7 +634,8 @@ EOF
sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h>
main()
int
main ()
{
if (!__power_pc())
exit(1);
@ -718,7 +719,8 @@ EOF
#include <stdlib.h>
#include <unistd.h>
int main ()
int
main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
@ -1621,6 +1623,7 @@ cat > "$dummy.c" <<EOF
#endif
#endif
#endif
int
main ()
{
#if defined (sony)

View File

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5.
.TH CONFIG.GUESS "1" "January 2024" "GNU config.guess (2024-01-01)" "User Commands"
.TH CONFIG.GUESS "1" "May 2024" "GNU config.guess (2024-04-03)" "User Commands"
.SH NAME
config.guess \- guess the build system triplet
.SH SYNOPSIS