Mail Archives: djgpp/1998/06/02/22:31:12
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 -