Microsoft KB Archive/84477

{|
 * width="100%"|

#pragma optimize( &quot;&quot;, off|on ) Does Not Affect P-Code

 * }

Q84477

7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool -- The information in this article applies to: - The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- SUMMARY ======= Microsoft 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 &quot;q&quot;. MORE INFORMATION ================ This 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(&quot;&quot;, off) #pragma optimize(&quot;q&quot;, off) #pragma optimize(&quot;&quot;, on) #pragma optimize(&quot;q&quot;, 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 &quot;q&quot;. Sample Code --- /* Compile options needed: /Oq /Fc */ #include void HamAndEggs( void ); // The following directive should turn off p-code generation. #pragma optimize( &quot;&quot;, off ) void main { printf( &quot;This function is using p-code\n&quot; ); HamAndEggs; } // The following line turns p-code generation off. #pragma optimize ( &quot;q&quot;, off ) // The following line should turn p-code generation on. #pragma optimize( &quot;&quot;, on ) void HamAndEggs { printf( &quot;This function is not using p-code\n&quot; ); } Additional reference words: kbinf 7.00 1.00 1.50 8.00 8.00c pcode KBCategory: kbtool KBSubcategory: CLIss

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCVCComp