www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/13/13:06:58

Date: Sun, 13 Sep 1998 13:04:21 -0400 (EDT)
Message-Id: <199809131704.NAA03113@delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: sl AT psycode DOT com DOT REMOVE_THIS
CC: djgpp AT delorie DOT com
In-reply-to: <iCdMCj1ZQ5j2-pn2-U1bLOKdKkegi@portY12.lanzen.net>
(sl AT psycode DOT com DOT REMOVE_THIS)
Subject: Re: DJGPP/GCC bug found

> 	I'm unsure who is to blaim for the following bug, but here it is:

Apparently, you must blame your teacher.

> 	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! Anyway, I am using DJGPP 2.1 with GCC 2.8.1.. Try and 

main returns int, regardless of what you put in your source code.
That's the standard, and gcc knows it.  main is a special function
that has certain well-known semantics in C and C++ and you can't just
do what you want with it.

Since main returns an int, gcc will complain if you return anything
else (or return nothing).

> compile the code yourself. You will get the same results.. As for why 
> I am using "void main", I am not; this code was provided to me by my 
> teacher, so go blaim him <g> .. I know better ..

OK, it's your teacher's bug.  Tell him/her that he/she is WRONG and
that main MUST return an int to be correct.

- Raw text -


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