From 9d1d9d5260975a42b71a663084cc585fa8caade4 Mon Sep 17 00:00:00 2001 From: Petr Vorel Date: Mon, 13 May 2024 16:55:28 -0400 Subject: [PATCH] config.guess: Avoid implicit int in definitions of main. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: Zack Weinberg Signed-off-by: Dmitry V. Levin --- config.guess | 9 ++++++--- doc/config.guess.1 | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.guess b/config.guess index f6d217a..b7f5e24 100755 --- a/config.guess +++ b/config.guess @@ -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 - main() + int + main () { if (!__power_pc()) exit(1); @@ -718,7 +719,8 @@ EOF #include #include - int main () + int + main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); @@ -1621,6 +1623,7 @@ cat > "$dummy.c" <