extern

Karl Heuer karl at haddock.ima.isc.com
Sun Jul 1 04:56:24 AEST 1990


In article <277 at taumet.com> steve at taumet.UUCP (Stephen Clamage) writes:
>The usual trick is then to do something like this:
>	#define EXTERN extern

In rebuttal, I'd like to mention that many of us find this grotesque, and
prefer to use
	/* header.h */
	extern int foo[20];
	extern double bar;

	/* something.c */
	#include "header.h"
	int foo[20];
	double bar = 3.0;
which is also completely portable, doesn't require preprocessor games, and
allows the objects to have initializers (this can sometimes be done with your
method too, but it makes it even uglier).  Since the defining source file also
includes the header, you can't get them out of sync.

Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint



More information about the Comp.lang.c mailing list