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

**URL:** <https://forums.unrealengine.com/t/how-to-disable-optimization-for-whole-project-c-for-debug/477074>\
**Category:** C++\
**Tags:** debug, Optimization, unreal-engine, CPP, question\
**Created:** [January 11, 2021, 9:06am UTC](https://forums.unrealengine.com/t/how-to-disable-optimization-for-whole-project-c-for-debug/477074 "2021-01-11T09:06:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_d4b71f88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d4b71f88](https://forums.unrealengine.com/u/anonymous_user_d4b71f88)\
**Post date:** [January 11, 2021, 9:06am UTC](https://forums.unrealengine.com/t/how-to-disable-optimization-for-whole-project-c-for-debug/477074/1 "2021-01-11T09:06:06Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![ZVReKK](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZVReKK](https://forums.unrealengine.com/u/ZVReKK)\
**Post date:** [February 2, 2021, 5:21pm UTC](https://forums.unrealengine.com/t/how-to-disable-optimization-for-whole-project-c-for-debug/477074/2 "2021-02-02T17:21:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Aberroco](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aberroco](https://forums.unrealengine.com/u/Aberroco)\
**Post date:** [March 5, 2021, 4:05pm UTC](https://forums.unrealengine.com/t/how-to-disable-optimization-for-whole-project-c-for-debug/477074/3 "2021-03-05T16:05:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ZVReKK](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZVReKK](https://forums.unrealengine.com/u/ZVReKK)\
**Post date:** [March 10, 2021, 7:15am UTC](https://forums.unrealengine.com/t/how-to-disable-optimization-for-whole-project-c-for-debug/477074/4 "2021-03-10T07:15:07Z")

</div>

If you see a .build.cs file, it’s a module.  
[Documentation](https://docs.unrealengine.com/en-US/ProductionPipelines/BuildTools/UnrealBuildTool/ModuleFiles/index.html) 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.

---

<div class="post-metadata">

**Author:** ![blurryroots](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/blurryroots/32/490122_2.png) [@blurryroots](https://forums.unrealengine.com/u/blurryroots)\
**Post date:** [May 6, 2022, 9:56am UTC](https://forums.unrealengine.com/t/how-to-disable-optimization-for-whole-project-c-for-debug/477074/5 "2022-05-06T09:56:27Z")

</div>

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:

```auto
// 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.

---

<div class="post-metadata">

**Author:** ![TepDaddy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TepDaddy](https://forums.unrealengine.com/u/TepDaddy)\
**Post date:** [February 3, 2025, 6:02pm UTC](https://forums.unrealengine.com/t/how-to-disable-optimization-for-whole-project-c-for-debug/477074/6 "2025-02-03T18:02:35Z")

</div>

You can put this flag to disable optimizations for the file you’re working in  
`PRAGMA_DISABLE_OPTIMIZATION`

> **[Visual Studio Tips and Tricks in Unreal Engine | Unreal Engine 5.5...](https://dev.epicgames.com/documentation/en-us/unreal-engine/visual-studio-tips-and-tricks-in-unreal-engine)**
>
> Useful tips and tricks for working on Unreal Engine content in Visual Studio
