delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/28/15:00:08

Date: Sun, 28 Dec 1997 14:58:40 -0500 (EST)
Message-Id: <199712281958.OAA00982@delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: nrotem AT johnbryce DOT co DOT il
CC: djgpp AT delorie DOT com
In-reply-to: <Chameleon.971228213913.nrotem@netvision.netvision> (message from
Noam Rotem on Sun, 28 Dec 97 21:34:51 PST)
Subject: Re: Filtering warnings

> >>When I'm using the -Wall switch, I get also the warning about 
> >>main, defaulting to 'int'...
> 
> My declaration was: *main()* not *void main()*. 
> main() indeed defaults to int main(), but the question was how to use the 
> shortcut without being warned.

I suspect that before ANSI C, people would declare functions without
return types, and return *pointers*.  Thus, the compiler is warning
you that it's defaulting to int in case you expected to return
something else with it (that might be a different size nowadays).

GCC's policy is that warnings are for cases where the compiler thinks
you might have made a mistake, but it's possible that you knew what
you were doing, and so it will do what it thinks is the right thing,
but warn you in case it's wrong.  If it knows you made a mistake, it
issues an error instead.

- Raw text -


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