Why static forward references

Chris Torek chris at mimsy.UUCP
Tue Jan 6 11:45:58 AEST 1987


Doug Gwyn quotes something that is misleading, and seems to have
mislead:
>>In article <6927 at ki4pv.UUCP> tanner at ki4pv.UUCP (Tanner Andrews) writes:
>>>extern char *blunge();			/* declare blunge */
>>>char *gork() { return(blunge(69)); }	/* use blunge */
>>>static char *blunge(arg) int	arg; { /* body of blunge here */ }

>In article <4870 at mimsy.UUCP> I wrote:
>>But if the ANSI standard mandates that the code author must use
>>`extern' or `static' on forward declarations, these compiler writers
>>can save themselves the trouble of doing things right, or of fixing
>>their linkers.  And that appears to be the entire motivation.

In article <5478 at brl-smoke.ARPA> gwyn at brl-smoke.ARPA (Doug Gwyn ) writes:
>I don't think that is the issue at all.  The question is, WHICH
>"blunge" should be used in the above example?

I think the static one should be used.  But we were trying to
_eliminate_ the `extern' from the first declaration.  The above
example is one we would like to eradicate.

>According to the "declare things correctly before you use them"
>school, the external blunge() should be used, not the internal
>one.

But this is not in fact what happens with any of the compilers I
have used.  (Not that I have used many C compilers.)  I also happen
to think it is a bad idea to force one to encode the visibility of
a function in its type declarations as well as in its definition,
although I can see how others would feel otherwise.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris at mimsy.umd.edu



More information about the Comp.lang.c mailing list