www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/15/22:04:56

Xref: news2.mv.net comp.os.msdos.djgpp:5012
From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to tell djgpp NOT to optimate a line of code
Date: Fri, 14 Jun 1996 23:15:03 -0700
Organization: Alcyone Systems
Lines: 22
Message-ID: <31C254E7.65FBF938@alcyone.com>
References: <Pine DOT VUL DOT 3 DOT 91 DOT 960613123358 DOT 3422E-100000 AT zeus DOT adv-boeblingen DOT de>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Lennart Steinke wrote:

> I wrote a ISR which hook into the timer interrupt and updates
> a global variable.
    ...
> ist there a possibilty to tell gcc not to touch the code
> (similar to the __volatile__ keyword)?

Yes.  It's called the volatile keyword.  :-)

Declare the global variable as being `volatile'.  Then the compiler won't
optimize the comparison away.

The `volatile' keyword is ANSI C, so you don't have to worry about it being
nonportable.

-- 
Erik Max Francis &tSftDotIotE && http://www.alcyone.com/max && max AT alcyone DOT com
San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect
H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade
Omnia quia sunt, lumina sunt. && Dominion, GIGO, GOOGOL, Omega, Psi, Strategem
"Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019