Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Now this is just annoying. Date: Mon, 03 Feb 2025 15:21:20 -0800 Organization: None to speak of Lines: 57 Message-ID: <878qqmsjgv.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Tue, 04 Feb 2025 00:21:21 +0100 (CET) Injection-Info: dont-email.me; posting-host="7c053bde0db3c430106d8966ac66d924"; logging-data="1580420"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2spS42RN3HwbVv5XCiw9w" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:v7BGmMpbl9wKgaGTDqODfsoUZxs= sha1:ChJ2oZDGeP7BVDVsXyXzT4L0Baw= Xref: csiph.com comp.lang.c++:121493 scott@slp53.sl.home (Scott Lurndal) writes: > James Kuyper writes: >>On 2/2/25 13:05, Scott Lurndal wrote: >>> $ gcc --version >>> gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3) >>> >>> $ g++ -O3 -o /tmp/a /tmp/a.cpp /tmp/a.cpp:4:1: warning: 'int main(int, >>> const char**, const char**, const char**)' takes only zero or two >>> arguments [-Wmain] >>> 4 | main(int argc, const char **argv, const char **envp, const char >>> **auxv) >>> | ^~~~ >>> >>> So much for backward compatibility and support for the original C++ >>> operating >>> environment (unix). >> >>Does it prevent the code from compiling and executing correctly in a >>Unix environment? If not, it has no effect on the backwards >>compatibility of the compiler. > > Yes, if the programmer had used -Werror, as many do. This is > a recent change to g++. That appears not to be the case. I see the same warning by default with every version of g++ going back to 5.3.0, from 2015. gcc (the C compiler) does not produce this warning by default, but it can be enabled by "-Wmain", which is included in "-Wall". I just tried 30 versions of g++ from 5.3.0 up to 14.2.0; they all produced the warning. >>Those are the only two forms that all implementations of C and C++ are >>required to accept, though they are allowed to accept additional >>implementation-defined forms. Those statements have been true of both >>languages for as long as they've been standardized. >>This is only a warning - fully conforming implementations are allowed to >>warn about anything they want, such as failing to use taboo words for >>user-defined identifiers. >>The warning is the default for C++, and is turned on by -Wall and >>-Wpedantic for C, because it's a reasonable thing to warn about. But if >>you disagree with that assessment, it can be turned off by -Wno-main > > My problem is that g++ never warned until recently, so it broke a build > that used -Werror. See above. Is it possible that you've been using a *very* old version of g++, or that you've had some kind of configuration that dissables the warning, or that you've confused the C++ and C compilers? See if you can confirm that some version of g++ does not produce this warning by default. If so, the details could be interesting. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */