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: Sun, 02 Feb 2025 15:22:07 -0800 Organization: None to speak of Lines: 24 Message-ID: <87msf4lyow.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 03 Feb 2025 00:22:08 +0100 (CET) Injection-Info: dont-email.me; posting-host="10bbb6812bbf5f3cc93ff155f0b4a01f"; logging-data="963250"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Z4iAySsO+RcBxbs4VzLG1" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:taD6v0NkEXfhPC4Kj+U7F0WfWdg= sha1:J37NFQVrgfmPPsC9QNeUzcnNs7c= Xref: csiph.com comp.lang.c++:121483 scott@slp53.sl.home (Scott Lurndal) writes: > $ 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). Backward compatibility is exactly what you're seeing here. g++ is warning you that your main function doesn't have one of the two forms required by the C++ standard, but it's still compiling it. You can even disable the warning with "-Wno-main". BTW, the warning is slightly misleading. It's not emitted if main is defined with 3 parameters (argc, argv, envp). -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */