From: "Oliver Roese" Newsgroups: comp.os.msdos.djgpp References: <84EFC73E5BDD300C DOT 85A7FCC32BD1270B DOT F7CB654E8161FA9A AT lp DOT airnews DOT net> Subject: Re: return type for `main' changed to `int' Date: Sun, 17 Oct 1999 18:49:40 +0200 Lines: 60 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 NNTP-Posting-Host: pm1-76.xnc.de Message-ID: <380a163a@news.xenologics.com> X-Trace: 17 Oct 1999 20:32:26 +0100, pm1-76.xnc.de Organization: .XNC GmbH To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Rodeo Red schrieb in im Newsbeitrag: 84EFC73E5BDD300C DOT 85A7FCC32BD1270B DOT F7CB654E8161FA9A AT lp DOT airnews DOT net... (...) > This command line: > > gcc -c -Wall hello.cpp > > is supposed to produce the object file hello.o, but doesn't . Instead I > get this message: > hello.cpp:4: return type for `main' changed to `int' > > What does this mean ? > > > here is hello.cpp: > > #include > > void main () > { > cout <<"Hello world!\n"; > } > (...) I tried to compile the program you provided, with the switches you told (vers. 2.95). Here is what I got: >gcc -c -Wall hello.cpp hello.cpp:4: warning: return type for `main' changed to `int' gcc simply omits a warning, since you told it to provide (mostly) all warnings, but compiles your file without problems! As you may already know, it is in C allowed but not recommend to alter the return type of "main" (since then the return-value is unspecified). But is it for a cpp-program? I searched a locale copy of an Ansi-C++ draft and here is what i found: (...) This function is not predefined by the implementation, it cannot be overloaded, and its type is implementation-defined. All implementations shall allow both of the following definitions of main: int main() { /* ... */ } and int main(int argc, char* argv[]) { /* ... */ } (...) If control reaches the end of main without encountering a return statement, the effect is that of executing return 0; (...) According to this, you were right to report this warning as an anomaly for a cpp-program. Best Regards Oliver Roese