main() - argc,argv

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Dec 1 11:03:03 AEST 1989


In article <1093 at nsscb.UUCP> nrg at nsscb.UUCP (G.Narotham Reddy) writes:
>I would like to know what happens if main() is passed more than two arguments?

It depends on details of the implementation.
Some UNIX systems actually have done this; on those systems
one may have to define main() with three arguments in order to
obtain correct linkage with the run-time startoff module.
X3J11 decided that this was an unwarranted change to a fundamental
hosted-C interface and would not be sanctioned by the C Standard.
IEEE P1003 had at one time intended to follow UNIX System V's
lead in this, but the problems were pointed out and they backed
down on it.  (Unfortunately, the alternative hook for the extra
information, a global variable called "environ", was not dealt
with properly by the combination of X3J11 and P1003, causing much
last-minute scrambling to try to maintain 1003.1/X3.159 compatibility.)

Note that there have been a series of type compatibility screw-ups
by AT&T UNIX developers in the past, including relying on a -1
"value" (ill-defined) for pointers as a portable error indicator.
I don't know why these happened, since I KNOW there were individuals
within Bell Labs who could have given proper advice on these matters.



More information about the Comp.lang.c mailing list