Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!PEPRBV%CFAAMP.BITNET@husc6.harvard.EDU From: PEPRBV%CFAAMP.BITNET@husc6.harvard.EDU (Bob Babcock) Newsgroups: comp.lang.c Subject: Re: global data in C programming... Message-ID: <12471@brl-adm.ARPA> Date: 17 Mar 88 18:48:43 GMT Sender: news@brl-adm.ARPA Lines: 14 >>how does one use global data in C programming? Basically, the global variables should be declared with the extern keyword in every source file but one. (Note that this is really a linker requirement; I'm not sure whether all environments require this.) The way I do this is in the include file, I put EXTERN int x,y; in main (before the file is included) I put #define EXTERN and in all other routines I put #define EXTERN extern If the global variable is explicitly initialized, you need to put in #ifdef's of some sort so that the initialization is only done where the extern keyword is absent.