cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/02/22:31:12

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: A nice trap! (2)
Date: Tue, 02 Jun 1998 21:55:17 -0400
Organization: Two pounds of chaos and a pinch of salt.
Lines: 40
Message-ID: <3574AD05.98558C39@cs.com>
References: <35715AA9 DOT 4222FD24 AT net4you DOT co DOT at> <35718841 DOT 1129 AT cs DOT com> <slrn6n7qds DOT 46 DOT loki AT anima DOT nectar DOT com DOT au> <357488F9 DOT 6054 AT cs DOT com> <slrn6n99fl DOT 44 DOT loki AT anima DOT nectar DOT com DOT au>
NNTP-Posting-Host: ppp147.cs.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

loki wrote:
> 
> >1) The return value is used as the program's exit code, and may be used
> >by any program that invokes yours.
> 
>   I guess it depends; if I knew no other program would ever try to invoke
> mine I might well declare main() as returning void, mostly so I didn't have
> to bother writing a return at the bottom.  Call me lazy :)

Many people say that.  To be completely truthful, can you really say
that no program will ever call yours?  Is the risk of problems, however
slight, worth 10 extra characters worth of code?

[snip]
>   Further shortenings are possible (I suppose you could use K&R style
> braces and chop off one whole line!) but I don't think it's a very
> productive exercise to go any futher, heh.

I was referring to total number of characters, not stylistic points. 
:-)

>   Of course, you can argue that it's poor style to have a function not
> explicitly declare its return type, and I would agree.  Pretty much ditto
> about the empty parameter list.

You just proved my point.  In fact, the later versions of gcc complain
about implicit return types with '-Wall'.  Empty parameter lists are a
questionable point, but the way I see it, that definition of main()
doesn't accept "any number and type of arguments"; it accepts exactly
zero arguments, so void is appropriate.

It's a silly discussion; let's end it.

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "A woman is not property, and hus-   |
|       aka Fighteer I       | bands who think otherwise are living |
|   mailto:fighteer AT cs DOT com   | in a dreamworld."                    |
| http://www.cs.com/fighteer |                - Lazarus Long        |
---------------------------------------------------------------------

- Raw text -


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