extern int f(); VS int f();

Vick Khera khera at juliet.cs.duke.edu
Tue Feb 13 02:54:28 AEST 1990


In article <2912 at hcx1.SSD.CSD.HARRIS.COM> brad at SSD.CSD.HARRIS.COM (Brad Appleton) writes:
>
>Are the following function declarations equivalent?
>
>(1)	extern int foo();
>(2)	int foo();
>
>Brad Appleton		"... and miles to go before I sleep."


Under Microsoft C 5.1, the two declarations were just slightly different.
If I put "extern int foo(/* some prototype */);" in my header files, then
when I compiled the file containing foo() [which #included the header file],
I would not get any error messages if the parameter list or function types
mismatched.  If the header file contained "int foo(/* some prototype */);"
then the I would get the proper messages.  In both cases, other files (not
containing the definition of foo() ) would compile the same, generating the
appropriate messages.

A friend of mine tells me that he worked with a compiler recently that
would complain about a function having a duplicate declaration if the
extern form was not used when the file containing the definition was
compiled.

								v.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vick Khera                              Department of Computer Science
ARPA:   khera at cs.duke.edu               Duke University
UUCP:   ..!{mcnc,decvax}!duke!khera     Durham, NC 27706



More information about the Comp.lang.c mailing list