Xref: utzoo comp.sys.amiga:76106 comp.sys.amiga.tech:17631 Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!samsung!uunet!cbmvax!bj From: bj@cbmvax.commodore.com (Brian Jackson) Newsgroups: comp.sys.amiga,comp.sys.amiga.tech Subject: Re: "chip" in SAS C Message-ID: <17211@cbmvax.commodore.com> Date: 8 Jan 91 04:04:59 GMT References: <1991Jan4.031246.20044@cs.uoregon.edu> <1991Jan6.092515.6970@cs.uoregon.edu> <12545@hacgate.UUCP> Reply-To: bj@cbmvax.commodore.com (Brian Jackson) Organization: Commodore, West Chester, PA Lines: 39 In article <12545@hacgate.UUCP> johnl@SDFSUN1.hac.com (John Lee) writes: >In article <1991Jan6.092515.6970@cs.uoregon.edu> rlittle@cs.uoregon.edu (Robert A. Little) writes: >>Two things...First: I mistyped the message--my code read: >> >>USHORT chip ImageData[]={0xF7000,0xEFFF,...}; >> >>Second: >>The compiler would only compile the code if I moved it from within a procedure >>to a global declaration...it compiles fine now...my only question is, Why? >>Why won't it compile if the declaration is made within a procedure? Some type >>of a scope problem? > >Aha! There's the rub... You cannot initialize aggregate automatic variables. >You'll need to make it static by: 1) moving it outside the procedure, making >it global, or 2) inserting the storage class keyword 'static' in front. ANSI C allows the initialization of aggregate auto variables as long as the initializers are constants (which these are.) See pages 85-86 and page 219 of the second edition K&R. Of course, the 'chip' keyword in SAS C makes this a bit unlikely, but the ANSI C compilers should accept it. The following compiles and runs just fine with Aztec 5.0d: main() { int foo[] = { 0,1,2,3 } ; int x ; for( x = 0 ; x < 4 ; x++ ) printf("x = %d\n", foo[x] ) ; } bj ----------------------------------------------------------------------- | Brian Jackson Software Engineer, Commodore-Amiga Inc. GEnie: B.J. | | bj@cbmvax.cbm.commodore.com or ...{uunet|rutgers}!cbmvax!bj | | "Paradise is exactly like where you are right now, only better." | -----------------------------------------------------------------------