From: j DOT aldrich6 AT genie DOT com Message-Id: <199606140018.AA090101538@relay1.geis.com> Date: Fri, 14 Jun 96 00:02:00 UTC 0000 To: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Subject: Re: How to tell djgpp NOT to o Reply to message 2000314 from STEINKE AT ZEUS. on 06/13/96 2:12PM >ist there a possibilty to tell gcc not to touch the code >(similar to the __volatile__ keyword)? There are two ways you could accomplish this. The simplest is to just declare 'g' volatile, which means that the compiler cannot assume that at any given time it will hold the same value that it held previously. This prevents it from optimizing 'g' by putting it in a register or by simply ignoring it. The way to do this is simple: volatile int g; /* int can be any type, of course */ The other more complicated way is to declare the function or functions in which 'g' is used volatile, in which case the compiler won't touch _anything_ inside the function. For example: volatile int dont_optimize_me( int foo ) { ... } At least, I think that's how it's done, having never done so myself. However, this is by far the hard way to do things. Just use 'volatile' when declaring 'g', and you'll be fine.BTW, if you don't like 'volatile' because it's an ANSI-only keyword, just remember that the number of traditional compilers out there is shrinking on a daily basis. Anyone who still has one of those things should be dragged out and shot. ;) In a traditional compiler, AFAIK there is no way to declare a variable not to be optimized, but you can't really rely on anything that is non-ANSI to be consistent with any other compiler. John