global declarations

cottrell at nbs-vms.ARPA cottrell at nbs-vms.ARPA
Sat Jan 5 02:43:13 AEST 1985


/*
i have done both of what lauren & yao suggested. have a file called global.h
which contains:

	#ifndef	GLOBAL
	#define	GLOBAL	extern
	#endif
	GLOBAL	int	foo;
	GLOBAL	char	bar;

all files include global.h. from here there are two ways to go about things.
1) a file global.c contains:

	#define	GLOBAL
	#include "global.h"	/* optional */
	int	foo = 1;
	char	bar;

not every var need be either initialized or even declared unless the
compiler (bdsc for one?) requires it. there is nothing wrong with both a
declaration (extern) and a definition (no extern) appearing in the same
file, and it seems clear to me. this is the centralized approach.

2) other files just declare a var where they need to, probably only if
   they desire initialization.

3) i only said two

"where's the beef?"
"dont listen to what i say, hear what i mean"

*/



More information about the Comp.lang.c mailing list