Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!necntc!ima!haddock!karl From: karl@haddock.UUCP (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: portability and standards Message-ID: <609@haddock.UUCP> Date: Mon, 22-Jun-87 21:21:13 EDT Article-I.D.: haddock.609 Posted: Mon Jun 22 21:21:13 1987 Date-Received: Wed, 24-Jun-87 04:11:13 EDT References: <2290@calmasd.GE.COM> <16939@cca.CCA.COM> <17198@amdcad.AMD.COM> <2166@dg_rtp.UUCP> Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer) Distribution: world Organization: Interactive Systems, Boston Lines: 23 In article <2166@dg_rtp.UUCP> meissner@dg_rtp.UUCP (Michael Meissner) writes: >I use a somewhat similar scheme that allows simple initializations: > #ifndef GLOBAL > #define GLOBAL extern > #define INIT(x) > #endif >in the main program before the includes, I define: > #define GLOBAL > #define INIT(x) = x I used to use an equivalent trick, until I discovered that it's okay to have a declaration *and* a definition in the same file. Now I put declarations into the include file (without the above macros), and also include this file in the main program or globals.c or whatever, where I have the definitions. If they don't match, the compiler will say so. This means I have to update both the header file and the globals.c file if I change things, but I consider that a small price to pay. On the flip side, I can change the value of a global without editing the header; this is useful in a "make" environment. (Also, it neatens things up -- I never liked having to use those macros.) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint