Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!brl-tgr!tgr!cottrell@nbs-vms.ARPA From: cottrell@nbs-vms.ARPA Newsgroups: net.lang.c Subject: global declarations Message-ID: <6989@brl-tgr.ARPA> Date: Fri, 4-Jan-85 11:43:13 EST Article-I.D.: brl-tgr.6989 Posted: Fri Jan 4 11:43:13 1985 Date-Received: Sun, 6-Jan-85 00:41:27 EST Sender: news@brl-tgr.ARPA Organization: Ballistic Research Lab Lines: 32 /* 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" */