#pragma optimize( "", off|on ) Does Not Affect P-CodeLast reviewed: July 17, 1997Article ID: Q84477 |
7.00 | 1.00 1.50
MS-DOS | WINDOWS
kbtool
The information in this article applies to:
SUMMARYMicrosoft C/C++ compilers do not turn p-code optimizations on or off by using the #pragma optimize preprocessor directive if the string passed into the pragma is an empty string. The pragma optimize does work as expected if the string contains a "q".
MORE INFORMATIONThis is expected behavior. The /Oq compiler option switch actually specifies more than an optimization--it is a compiler mode change. For this reason it must be explicitly listed in the #pragma optimize directive for it to be affected. The following is an example of turning off all optimizations and restoring default optimizations, including p-code:
#pragma optimize("", off) #pragma optimize("q", off) #pragma optimize("", on) #pragma optimize("q", on)In the following sample code, the main function is compiled with p-code, and the function HamAndEggs is not. The #pragma optimize statements with empty strings have no effect. This can be verified by examining a mixed source-assembly listing. Note that the optimize with p-code option (/Oq) must be specified on the command line in order to use the optimize pragma with "q".
Sample Code
/* Compile options needed: /Oq /Fc */ #include <stdio.h> void HamAndEggs( void ); // The following directive should turn off p-code generation.#pragma optimize( "", off )
void main( ){ printf( "This function is using p-code\n" ); HamAndEggs( );}
// The following line turns p-code generation off.#pragma optimize ( "q", off )
// The following line should turn p-code generation on.#pragma optimize( "", on )
void HamAndEggs( ){ printf( "This function is not using p-code\n" );}
|
Additional reference words: kbinf 7.00 1.00 1.50 8.00 8.00c pcode
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |