is there any way to disable compiler optimisation for a specific line of code in Visual studio?
Use the command-line option -O0 (-[capital o][zero]) to disable optimization, and -S to get assembly file. Look here to see more gcc command-line options.
In this dialog, open the Build page and select Active (Debug) from the Configuration dropdown list at the top of the dialog. Then, on the same Build page, disable the Optimize code checkbox and click the Advanced button. Click the image to enlarge it.
The default optimization level for compiling C programs using GCC is -O0. which turns off all optimizations according to GCC documentation. for example: gcc -O0 test.
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 )
You can use this optimize pragma to control this on a function basis
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With