Sign in to follow this  

MSVC++ 2010 optimization option?

This topic is 2320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

does anyone know of a way to allow full optimizations of code compiled on MVC++ 2010 except for the elimination of code that performs nothing relevant. For example


[code]int main()
{
int var;

var++;

return 0;
}[/code]


[code]
_main PROC ; COMDAT

; 3 : int var;
; 4 :
; 5 : var++;
; 6 : return 0;

xor eax, eax

; 7 : }

ret 0
_main ENDP[/code]

since var++ doesnt get stored in a variable it's operation is omitted when the binary is compiled from MSVC++. What exact option can i change in order to prevent this while leaving other optimizations on!?

Share this post


Link to post
Share on other sites
If you're trying to create a location where you can place a debugger breakpoint, you can insert a nop instruction via inline assembly (__asm nop) or a compiler intrinsic (__nop()). I haven't tried the compiler intrinsic but the optimizer definitely won't try to remove inline assembly.

Share this post


Link to post
Share on other sites

This topic is 2320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this