This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC warnings for unused global variables


On Fri, 2 May 2003 tm_gccmail@mail.kloo.net wrote:

> On Fri, 2 May 2003, Richard Henderson wrote:
> 
> > On Fri, May 02, 2003 at 08:38:44AM -0700, Kean Johnston wrote:
> > > I don't know if such code exists, but it wouldn't surprise me terribly
> > > if some smart bloke somewhere has organised, through link editor
> > > trickery or other object-file manipulation, that code like:
> > > 
> > > static volatile int foo;
> > > 
> > > void doit (void)
> > > {
> > >   foo = 1;
> > >   foo = 2;
> > > }
> > > 
> > > actually orchestrates that because the symbol is marked as volatile,
> > > whether static or not, that it is mapped to some I/O port or special
> > > memory location or any number of possible things, and that the mere act
> > > of assigning a value to it writes data to the port.
> > 
> > I suppose it's not impossible, however, that it's one of the
> > least straightforward ways to accomplish this.  If I were going
> > to have the link-editor place foo on some I/O port, then I'd
> > declare it "extern", not "static".
> > 
> > > I belive that THAT
> > > kind of trickery was the intent behind volatile.
> > 
> > We'll have to disagree then.  No one's come up with anything
> > convincing so far.
> > 
> > 
> > r~
> 
> We used a global volatile int for flags between the two SH2 processors on
> a Sega 32x game system. So there are legitimate reasons.
> 
> Toshi

Actually, I thought of two more:

2. Flag between mainline and interrupt code in a stand-alone ROM
application.

3. Flag between threads in a threaded application.

Toshi



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]