C++ Release編譯時如何對某段代碼不進行優化


optimize
#pragma optimize( "[optimization-list]", {on | off} )

Feature Only in Professional and Enterprise Edition    Code optimization is supported only in Visual C++ Professional and Enterprise Editions. For more information, see Visual C++ Editions.

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 Table 2.2.

Table 2.2   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 no aliasing across function calls. 
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. It either turns off all optimizations or restores them to their original (or default) settings.

#pragma optimize( "", off )
.
.
.
#pragma optimize( "", on ) 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM