coder1234567
coder1234567

Reputation: 551

is there any way to disable compiler optimisation for a specific line of code?

is there any way to disable compiler optimisation for a specific line of code in Visual studio?

Upvotes: 55

Views: 68501

Answers (1)

Mitch Wheat
Mitch Wheat

Reputation: 300559

No.

Only on a function-by-function basis using the optimize pragma:

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

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.

usage:

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

Upvotes: 151

Related Questions