Curious about function prototypes...

Mark Nagel nagel at ics.uci.edu
Sat Jun 11 02:50:34 AEST 1988


I have been using function prototypes a bit in LightspeedC for the Macintosh
and I was under the impression that the following was a correct prototype:

char *foo(char *c, int i);

for the function:

char *foo(c, i)
char *c;
int i;
{
  /* function body */
}

A friend of mine who is installing the GNU C compiler here tells me that the
ANSI standard has changed this so that the function body header must look
like the function prototype.  The GNU documentation says that something like
the above is now an error.  While I don't mind altering my habits to adapt to
the new way (if this is really the case), I am curious as to why this change
was adopted.  It seems to me that prototypes were designed such that modules
compiled separately would be able to determine the proper arguments without
access to the actual source of the other module(s).  What added benefit does
forcing duplication of the function prototype offer?  Or have we misunderstood
the GNU documentation?  I've read this group for quite a while and I thought
I would have heard about so drastic a change, but perhaps I missed it.

Mark D. Nagel      Department of Information and Computer Science, UC Irvine
                                        nagel at ics.uci.edu             (ARPA)
I'm not a graduate student,             {sdcsvax|ucbvax}!ucivax!nagel (UUCP)
but I play one on TV...



More information about the Comp.lang.c mailing list