On Wed, Apr 3, 2024, at 1:49 PM, Petr Vorel wrote: >> On Wed, Apr 3, 2024, at 1:01 PM, Petr Vorel wrote: >> > Although -Wmain-return-type is not considered as error (unlike >> > -Wimplicit-int on gcc 14 and clang 16), but just a warning, let's fix it >> > for the future. >> We want the end result to be >> int >> main (void) > > Sure, I'll do it in v2. May I know the reason for this?
As Jacob explained, this is a GNU style requirement. I don't think it is super important for test programs embedded in config.guess; it is unlikely that anyone would want to use on this file the tools that look for C function definitions by scanning for identifiers at the left margin. However, as other test programs in this file do conform to the convention, we should be consistent and use it throughout. Writing `(void)` instead of `()` for definitions and prototypes of functions that take no arguments is much more important; in the 1989 through 2011 revisions of the C standard, `()` declares a function that takes *an unspecified number* of arguments, not a function that takes no arguments. I'm actually kind of annoyed with the C committee for changing `()` to mean no arguments in C202x; if it were up to me I would have made that an *error*. > Does this rule (return type on a separate line) applies to main with > args (Ben is the author)? Yes it does, but the test program you quote has several other problems for new-fangled compilers. Let's fix all of those problems in a separate patch (I will send one). zw