Xref: utzoo comp.sys.amiga:76031 comp.sys.amiga.tech:17592 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool2.mu.edu!uunet!fernwood!portal!cup.portal.com!Radagast From: Radagast@cup.portal.com (sullivan - segall) Newsgroups: comp.sys.amiga,comp.sys.amiga.tech Subject: Re: "chip" in SAS C Message-ID: <37729@cup.portal.com> Date: 8 Jan 91 07:45:42 GMT References: <1991Jan4.031246.20044@cs.uoregon.edu> <1991Jan6.092515.6970@cs.uoregon.edu> <1342@tmiuv0.uucp> Distribution: na Organization: The Portal System (TM) Lines: 51 >> >> Second: >> The compiler would only compile the code if I moved it from within a procedu r >e >> 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 ty p >e >> 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. > Yikes! I thought I knew what all of the departures were between Turbo-C and ANSI. One of my favourite expressions is: { struct soandso thisisit = { 1, 2, 3 }; } in lieu of: struct soandso_default = { 1, 2, 3 }; function() { struct soandso thisisit; Thisisit = soandso_default; } -Sullivan_-_Segall (a.k.a. Radagast) _______________________________________________________________ /V\ E-Credibility: (n -- ME) The unguaranteed likelyhood that ' the electronic mail you are reading is genuine rather than someone's made up crap. _______________________________________________________________ Mail to: ...sun!portal!cup.portal.com!radagast or radagast@cup.portal.com } }