delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/22/06:45:09

From: horst DOT kraemer AT snafu DOT de (Horst Kraemer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP/GCC bug found
Date: Tue, 22 Sep 1998 10:33:59 GMT
Organization: [Posted via] Interactive Networx
Lines: 34
Message-ID: <360763ec.368074676@news.snafu.de>
References: <iCdMCj1ZQ5j2-pn2-U1bLOKdKkegi AT portY12 DOT lanzen DOT net> <6thlos$nc AT news-central DOT tiac DOT net> <iCdMCj1ZQ5j2-pn2-Td5LJRVKgtqF AT portE28 DOT Generation DOT NET>
NNTP-Posting-Host: n34-173.berlin.snafu.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 22 Sep 1998 00:54:19 GMT, sl AT psycode DOT com DOT REMOVE_THIS wrote:

>On Sun, 13 Sep 1998 23:55:49, "Martin Ambuhl" <mambuhl AT tiac DOT net> 
>wrote:
>
>> | In the above example, the compiler complains "return;" is used in a
>> |case where "main()" is non-void.. But as you can see, it IS declared
>> |to return void!
>> 
>> And illegally so.  g++ is smart enough to replace your illegal 'void'
>> with the
>> _required_ 'int'.
>
>	It's one thing to complain "main() must return int".. It's a totally 
>other matter when GCC complains of
>an error _IT_ causes .. What I mean by this is that it makes a 
>modification without telling me about it, therefore
>the error message which follows only serves to confuse the user.. Not 
>aid them ..

You are confusing two different programming languages.

In C, gcc will produce a warning that 'main' is not declared returning
'int' and that's it.

In C++, 'void main' is treated as an error. gcc (2.8.1) -Wall -ansi
-pedantic _will_ tell you that it changed the return type of 'main' to
'int' and therefore it will consistently complain that you didn't
return an int.


Regards
Horst

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019