Path: utzoo!utgpu!cunews!micor!latour!ecicrl!clewis From: clewis@ferret.ocunix.on.ca (Chris Lewis) Newsgroups: comp.unix.programmer Subject: Re: Optimizing out unreferenced variables Message-ID: <1475@ecicrl.ocunix.on.ca> Date: 7 May 91 13:53:45 GMT References: <608@elroy> Organization: Elegant Communications Inc., Ottawa, Canada Lines: 23 In article <608@elroy> davidk@dsinet (David Karr) writes: |I have been hearing about a tendency for certain Unix optimizing C compilers |to deal harshly with static variables declared in C modules that are not |referenced in that module. In other words, it will delete those variables |from the object file. A controversial example would be variables declared |in each module to hold RCS or SCCS information. Often these variables will |be declared as static, and only used by certain utilities to parse out the |version numbers from an executable binary. |I was told that the C compiler on AIX has this particular "affliction". Is |this a general feature of optimizing C compilers, and will more compilers |be adding this "feature" as time goes on, or is the AIX compiler a fluke? I |heard a mention that the HP 700 compiler would be doing this in the future. I've not tried this myself, but I would presume that if the compiler is ANSI compliant, you can probably declare such variables "volatile" and the compiler will not optimize them out. Volatile does work in similar situations with the RS/6000 compiler. -- Chris Lewis, Phone: (613) 832-0541, Domain: clewis@ferret.ocunix.on.ca UUCP: ...!cunews!latour!ecicrl!clewis; Ferret Mailing List: ferret-request@eci386; Psroff (not Adobe Transcript) enquiries: psroff-request@eci386 or Canada 416-832-0541. Psroff 3.0 in c.s.u soon!