extern question

Wayne A. Christopher faustus at ic.Berkeley.EDU
Fri Jul 1 08:43:58 AEST 1988


Is the following acceptable C code:

	extern int foo();

	bar()
	{
		int (*bla)() = foo;	/* CASE 1 */

		foo();			/* CASE 2 */
	}

	static int
	foo()
	{
		...
	}

In other words, should extern be interpreted as "possible forward
reference" (the way I'm using it), or "externally defined symbol"?  All
the compilers I have used handle case 2 ok, but one couldn't deal with
case 1.  Shouldn't they both work the same?

>From an aesthetic viewpoint, I like to use extern anywhere I declare
something but don't define it.  I think writing

	int foo();

for static functions is not as clear.

	Wayne



More information about the Comp.lang.c mailing list