main() arguments, was Re: typedef-ing an array

Kaleb Keithley kaleb at mars.jpl.nasa.gov
Wed Jul 4 02:53:18 AEST 1990


In article <25247 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:

>The first error is `void main': it must (yes must) be `int main', even
>if it never returns.  It may have either 0 arguments or two (int argc,
>char *argv).

I have a bone to pick here.  K&R 2nd Ed. states (p. 26):

A function need not return a value. [...] Since main is a function like any
other, it may return a value to its caller...

Furthermore, on p. 164 (Ibid.) it is stated:

Within main, return expr is equivalent to exit(expr).  exit has the
advantage...

If exit() is used rather than return, I submit that declaring main as 
returning type void is not only legal, but correct, as lint plus ANSI
compilers will complain that there is no return statement.

Second bone to pick is the assertion that main() has two arguments (???)
Since when?  What about the third allowable argument; envp?   I know that
both UNIX and DOS (M'soft C compilers anyway) support char **envp (or
char *envp[] if you will) as the third parameter to main.

kaleb at thyme.jpl.nasa.gov            Jet Propeller Labs
Kaleb Keithley

"So that's what an invisible barrier looks like"



More information about the Comp.lang.c mailing list