Xref: utzoo comp.sys.amiga:76102 comp.sys.amiga.tech:17629 Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!zardoz.cpd.com!tmiuv0!rick From: rick@tmiuv0.uucp Newsgroups: comp.sys.amiga,comp.sys.amiga.tech Subject: Re: "chip" in SAS C Message-ID: <1342@tmiuv0.uucp> Date: 7 Jan 91 16:44:40 GMT References: <1991Jan4.031246.20044@cs.uoregon.edu> <1991Jan6.092515.6970@cs.uoregon.edu> Organization: Technology Marketing Inc., Irvine, CA Lines: 51 In article <1991Jan6.092515.6970@cs.uoregon.edu>, rlittle@cs.uoregon.edu (Robert A. Little) writes: > In article <1991Jan4.031246.20044@cs.uoregon.edu> rlittle@comix.cs.uoregon.edu (Robert A. Little) writes: >> >> >>Q: Why does the following not work? >> >>.... >>USHORT chip Image={0xF700,0xF700}; >>.... >> >>The SAS C5.10 compiler produces "Error 25: modifiable lvalue required" >> >> > 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? Well, sort of. The ANSI C specification (ANSI X3.159-1989) states in section 3.5.7, "Initialization", lines 34-35: "If the declaration of an identifier has block scope, and the identifier has external or internal linkage, the declaration shall have no initializer for the identifier." Now, in English, that means that a variable declared inside some program block (such as a function) CANNOT have an initializer value. The stuff inside your curly braces is an initializer. You can't have it both ways. Ah, well. > Thanks > > --rob > rlittle@cs.uoregon.edu I'm not sure you really appreciate that, but you're welcome. 8-) -- ---------------------------------------------------------------------------- [- O] Rick Stevens ? EMail: uunet!zardoz!tmiuv0!rick -or- uunet!zardoz!xyclone!sysop V CIS: 75006,1355 (75006.1355@compuserve.com from Internet) "I'm tellin' ya, Valiant! Da whole ting stinks like yesterday's diapers!" - Baby Herman in "Who Framed Roger Rabbit" ----------------------------------------------------------------------------