
On 4/19/06, John Wilkinson
There is a pragma in VC6 that will activate or deactivate optimization. It can be used to wrap optimization-sensitive blocks of code. I do not remember what it is, though, and I do not have VC6 handy. I have used it, and it did alleviate an optimization-related bug.
From the MSDN:
#pragma optimize( "[optimization-list]", {on | off} ) Specifies optimizations to be performed on a function-by-function basis. The optimize pragma must appear outside a function and takes effect at the first function defined after the pragma is seen. The on and off arguments turn options specified in the optimization-list on or off. The optimization-list can be zero or more of the parameters shown in the following table. Parameters of the optimize Pragma Parameter(s)Type of optimization a Assume no aliasing. g Enable global optimizations. p Improve floating-point consistency. s or t Specify short or fast sequences of machine code. w Assume that aliasing can occur across function calls (achieves the same effect as /Ow). y Generate frame pointers on the program stack. These are the same letters used with the /O compiler options. For example: #pragma optimize( "atp", on ) Using the optimize pragma with the empty string ("") is a special form of the directive: When you use the off parameter, it turns the optimizations, listed in the table above, off. When you use the on parameter, it resets the optimizations to those that you specified with the /O compiler option. #pragma optimize( "", off ) . . . #pragma optimize( "", on ) HTH, Michael Fawcett