How to disable optimization for whole project C++ for debug?

Hi!I use a lot

#pragma optimize("", off)

to see variables values in debug mode

but it’s needs to put into each cpp file on the top.
How can I use same pragma macros for whole project at once place and at once time ?

2 Likes

At most there is the variable for the module:

OptimizeCode = CodeOptimization.Never;

And it’s probably possible to disable optimization by manually editing vcxproj/props files.

2 Likes

What is variable for the module? Where I can find one?

If you see a .build.cs file, it’s a module.
Documentation with an incomplete list.
All available module variables can be found in the file …\UE_4.xx\Engine\Source\Programs\UnrealBuildTool\Configuration\ModuleRules.cs
“OptimizeCode” is useful for the custom version of the engine, the game instance is easier to debug with the DebugGame build configuration.

Ran into similar issues when using compiler intrinsics, which clashes with some optimization flags. You might also want to disable the creation of precompiled header files via:

// Do not use PCH or Unity builds,
PCHUsage = ModuleRules.PCHUsageMode.NoPCHs;
// Nor Optimization, since intrinsics clash with those options :/
OptimizeCode = CodeOptimization.Never;

That did the trick for me.

1 Like