www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/08/12:22:02

From: resta AT imc DOT pi DOT cnr DOT it (Giovanni Resta)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: void main ?
Date: Mon, 07 Jul 1997 11:33:39 +0100
Organization: imc-cnr
Lines: 53
Message-ID: <resta-0707971133390001@mac-resta.imc.pi.cnr.it>
References: <resta-0307971339210001 AT mac-resta DOT imc DOT pi DOT cnr DOT it> <33BBABD2 DOT 3249 AT cornell DOT edu>
NNTP-Posting-Host: mac-resta.imc.pi.cnr.it
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <33BBABD2 DOT 3249 AT cornell DOT edu>, "A. Sinan Unur" <asu1 AT cornell DOT edu>
wrote:

> 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! 

Trolls ?

> 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()?

I'm sorry I do not know what a troll is. (Apart in Tolkien tales...).
Anyway I'm rather confident I'm not completely dumb as your kindly answer
slightly suggest :-). While I'm an (allegedly:-) theoretical computer scientist 
I've also 18-19 years of programming experience on machines ranging
from Commodore Vic-20 to Cray-T3D and I've used languages among
APL,Algol,Basic,Cobol,Lisp,Forth,Fortran, and of course C.
This self-centered preamble just to stress that when I say that in the past 5
years I used void main(), I mean that (1) now I use int main(), (2) 
I completely agree that void main() is not correct with respect to ANSI/ISO
standard, but that (3) I just wonder If anybody come out with an 
actual example of an error caused (directly of indirectly) by void main().

Thanks to all people that replied.
Giovanni.

- Raw text -


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