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

Brad Appleton brad at SSD.CSD.HARRIS.COM
Sat Feb 10 03:10:21 AEST 1990


Are the following function declarations equivalent?

(1)	extern int foo();
(2)	int foo();

I was just asked this question and I thought I knew a precise answer but
I find that I am a little fuzzy on this one! I thought (2) is like a
"forward" declaration in Pascal and that the only difference between these
two is that If I use (2) then I may define the function "foo" (give it 
a body) later on in the same file. Is this right?

I have looked in K&R (2e) and Harbison-Steele to try to find the answer
(as well as a few other texts) but nothing I have read seems to state the
difference between these two in precise terms (IMHO at least)! When would
I use (1) and not (2) (and vice-versa)? Is this dependent on the Compiler
Vendor? Is the answer different between ANSI-C and non-ANSI C?

I am somewhat new to the net and would also appreciate some constructive
feedback on whether this issue is worthy/appropriate for this newsgroup!
(any responses that are strictly feedback and not an answer to my question
stated in the subject line should probably reply by e-mail).

TIA (Thanks in Advance).
--
Brad Appleton		"... and miles to go before I sleep."

 +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
 | Harris Corporation			|	brad at csd.harris.com	   |
 | Computer Systems Division, M/S 161	|	{uunet,novavax}!hcx2!brad  |
 | 2101 West Cypress Creek Road		|				   |
 | Fort Lauderdale, FL 33309 USA	|	Phone: (305) 973-5007	   |
 +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
Brad Appleton		"... and miles to go before I sleep."

 +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
 | Harris Corporation			|	brad at csd.harris.com	   |
 | Computer Systems Division, M/S 161	|	{uunet,novavax}!hcx2!brad  |
 | 2101 West Cypress Creek Road		|				   |
 | Fort Lauderdale, FL 33309 USA	|	Phone: (305) 973-5007	   |
 +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+



More information about the Comp.lang.c mailing list