Proper use of "extern" ...

Doug Gwyn gwyn at brl-smoke.ARPA
Sun Jun 15 15:27:44 AEST 1986


In article <223 at comp.lancs.ac.uk> david at comp.lancs.ac.uk (David Coffield) writes:
-	static void f()
-	{
-		g();
-	}
-
-	static void g()
-	{
-	}
-
-At the top of this file do we put
-
-a) static void g() 	or
-
-b) extern void g()?

I would put

	static void g();

The rationale is that "extern" would imply that the name "g"
is to be "published", so that it would be visible outside
this file module.  Since this is not what is wanted, "extern"
is inappropriate.

Note that existing compilers do not all agree on the scope
or meaning of extern declarations in cases like this.  The
X3J11 standard is expected to clarify these semantics.



More information about the Comp.lang.c mailing list