Path: utzoo!mnetor!uunet!husc6!bu-cs!polygen!pablo From: pablo@polygen.uucp (Pablo Halpern) Newsgroups: comp.lang.c Subject: Re: initializing Message-ID: <24@polygen.UUCP> Date: 20 Jan 88 00:49:45 GMT References: <11276@brl-adm.ARPA> Reply-To: pablo@polygen.UUCP (Pablo Halpern) Organization: Polygen Corporation, Waltham, MA Lines: 21 In article <11276@brl-adm.ARPA> PEPRBV%CFAAMP.BITNET@husc6.harvard.EDU (Bob Babcock) writes: - If I want to initialize a global variable in an include file, and have - the initialization statement appear only in the main program, I can use - something like - - #ifdef MAIN_PROGRAM - #define INITIAL_VALUE(x) =x - #else - #define INITIAL_VALUE(x) - #endif - int i INITIAL_VALUE(1); - - But this doesn't work for an array, and I can't figure out anything - which does. Is there some trick I'm missing? Using your existing macros for INITIAL_VALUE(), you should be able to use the following declaration: int i[] INITIAL_VALUE( { 1, 2, 3, 4 } ); Other than a bit of uglyness, do you see anything wrong with that?