Mail Archives: djgpp/1997/07/05/14:48:22
Giovanni Resta wrote:
>
> Recently I read in a message by John M. Aldrich" <fighteer AT cs DOT com>
> that declaring the main as void, instead of int can produce
> unpredictable nasty effects.
>
> I always declared main as void in the past 5 years and
> I never get an error, so I'm curious about the topic.
> (I must admit that I never had to test the 'exit code' of a program,
> maybe that can change things)
>
trolls. what would life be like without them!
please refer to the ANSI/ISO C standard and the C FAQ. the latter is
available at:
http://www.cis.ohio-state.edu/hypertext/faq/usenet/C-faq/faq/faq.html
the sections of interest are:
11.12: Can I declare main() as void, to shut off these annoying "main
returns no value" messages?
11.14: I believe that declaring void main() can't fail, since I'm
calling exit() instead of returning, and anyway my operating
system ignores a program's exit/return status.
11.15: The book I've been using, _C Programing for the Compleat Idiot_,
always uses void main().
11.16: Is exit(status) truly equivalent to returning the same status
from main()?
-- Sinan
- Raw text -