-1

In order to learn Assembly, I am converting my C++ code into Assembly to see what it is being converted to, but before I do that I need to disable code optimization.

Now I can easily disable optimization by choosing Disabled (/Od) from C/C++ -> Optimization, but the problem is that there is another option for optimization in the Linker pane. So what values should I set in order to make sure that no optimization is being performed on my code (so I can have the same effect of the -O0 switch in gcc)?

enter image description here

Timo Geusch
  • 24,095
  • 5
  • 52
  • 70

1 Answers1

1

The simplest way to achieve your goal of turning off all optimizations is to build the project in debug mode. If you're turning off all optimizations in release more, you end up with settings very close to debug mode any.

IIRC the linker doesn't do any code optimizations per se unless you turn on "Use Link Time Code Generation" - so turn that off - as most of its other optimizations are folding segments etc which affect the location of the generated code but not necessarily the code itself.

You also want to look at this question and the accepted answer as that shows how you can get the compiler to emit an assembly code listing, which is going to be much more useful to you than disassembling the created binary.

Community
  • 1
  • 1
Timo Geusch
  • 24,095
  • 5
  • 52
  • 70
  • "which is going to be much more useful to you than disassembling the created binary" I am disabling optimization so I can view the generated Assembly code without optimization, and not to compile my project into an executable and then disassemble it. –  Dec 27 '14 at 23:25
  • If you're using the assembly listing output anyway, that's done by the compiler so there is no point in worrying about linker optimizations. – Timo Geusch Dec 28 '14 at 19:09