Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!brl-adm!brl-smoke!gwyn
From: gwyn@brl-smoke.ARPA (Doug Gwyn )
Newsgroups: comp.lang.c
Subject: Re: Why static forward references
Message-ID: <5478@brl-smoke.ARPA>
Date: Mon, 5-Jan-87 14:12:23 EST
Article-I.D.: brl-smok.5478
Posted: Mon Jan  5 14:12:23 1987
Date-Received: Mon, 5-Jan-87 22:00:04 EST
References: <6927@ki4pv.UUCP> <4870@mimsy.UUCP>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) )
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 26

In article <4870@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>In article <6927@ki4pv.UUCP> tanner@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 */ }

>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.

I don't think that is the issue at all.  The question is, WHICH
"blunge" should be used in the above example?  There might be
an external blunge() function also.  According to the "declare
things correctly before you use them" school, the external
blunge() should be used, not the internal one.  The one-pass
compilation model also requires this, since the meaning of the
reference to blunge() cannot depend on goings-on lexically later
in the source file.  This becomes even more significant when one
considers the fact that the rules for internal and external
symbol names (case folding, truncation, etc.) may well differ.

P.S.  "extern" is not required for such function declarations,
forward reference or no, since a function declaration with
neither "extern" nor "static" is taken to have external linkage if
linkage hasn't already been determined by a previous declaration.