Re: C and C++



Wade Ward said:

<snip>

int main(int argc, char* argv[])
This is a legal invocation of main?

No, it's a legal declarator for main.

For hysterical reasons, char *argv[] and char **argv are, in a parameter
context *ONLY*, identical in meaning. So it's the same as

int main(int argc, char **argv)

The other legal declarators for main are:

int main(void)

and any other declarator that takes the same parameter types (if any)
and returns the same type as either of the above definitions, and
*nothing else*. This gives you the freedom, such as it is, to omit void
from int main(void) and to use typedefs and stuff, but that's it,
really.

Implementations are, of course, free to allow other forms, but these
other forms are not guaranteed to be portable. For example, an
implementation is perfectly free to support:

double main(struct tm foo, ldiv_t bar, _custom_type ***baz)

but that doesn't mean other implementations have to agree.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.