Re: [PATCH] AC_LANG_INT_SAVE: Modernize function declarators (C89 and above).

Vincent Lefevre <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Message-ID <[email protected]>
On 2020-08-07 16:44:16 -0700, Paul Eggert wrote:
> On 8/7/20 1:01 PM, Vincent Lefevre wrote:
> > The program
> > 
> > int main(void)
> > {
> >    return 0;
> > }
> > 
> > compiles fine with g++, even using "-std=c++17 -pedantic".
> 
> I expect the problem was with non-GNU C++ compilers, not with g++. However,
> I'm not the C++ guy so I'm the wrong person to ask about the details. You
> could write to Bruno Haible - I think he was the one preferring 'int main ()
> ...'.

https://en.wikipedia.org/wiki/Void_type
https://stackoverflow.com/questions/51032/is-there-a-difference-between-foovoid-and-foo-in-c-or-c
https://softwareengineering.stackexchange.com/questions/286490/what-is-the-difference-between-function-and-functionvoid/286494

all say that both constructs are equivalent in C++. Thus
"int main(void)" is valid in C++.

WP says that the form without "void" is preferred, but does not say
why. I suppose that this is only for C++ programs (i.e. which can't
be compiled with a C compiler), in which case both constructs are
necessarily equivalent, and the form without void is more "logic".

-- 
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.