# How to exclude debug code when shipping game

**URL:** <https://forums.unrealengine.com/t/how-to-exclude-debug-code-when-shipping-game/290643>\
**Category:** Debugging, Optimization, & Profiling\
**Tags:** macro, debug, ignore, Shipping, unreal-engine, question\
**Created:** [August 11, 2014, 12:43am UTC](https://forums.unrealengine.com/t/how-to-exclude-debug-code-when-shipping-game/290643 "2014-08-11T00:43:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_566478b0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_566478b0](https://forums.unrealengine.com/u/anonymous_user_566478b0)\
**Post date:** [August 11, 2014, 12:43am UTC](https://forums.unrealengine.com/t/how-to-exclude-debug-code-when-shipping-game/290643/1 "2014-08-11T00:43:05Z")

</div>

Hello guys,

I would like to ask how can I exclude debug code like GEngine-\>AddOnScreenDebugMessage() during shipping. I use this kind of debug messages in my project, however I would like to be sure that these will not be displayed in shipped buiild. I prefer some macros because generated code will be cleaner and will not contain conditions and code that will never run.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [August 11, 2014, 2:50am UTC](https://forums.unrealengine.com/t/how-to-exclude-debug-code-when-shipping-game/290643/2 "2014-08-11T02:50:05Z")

</div>

There a definition flags like UE\_BUILD\_SHIPPING or UE\_BUILD\_DEBUG, each build configuration has it. So:

```
#if UE_BUILD_DEBUG

GEngine->AddOnScreenDebugMessage();

#endif

```

Will build that code only on debug config build, or

```
#if !UE_BUILD_SHIPPING

GEngine->AddOnScreenDebugMessage();

#endif

```

Will compile this code on everything other then shipping build config

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_566478b0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_566478b0](https://forums.unrealengine.com/u/anonymous_user_566478b0)\
**Post date:** [August 11, 2014, 9:40am UTC](https://forums.unrealengine.com/t/how-to-exclude-debug-code-when-shipping-game/290643/3 "2014-08-11T09:40:38Z")

</div>

Thank you for your help, that is exactly what I was looking for.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6334e343](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6334e343](https://forums.unrealengine.com/u/anonymous_user_6334e343)\
**Post date:** [August 11, 2014, 11:49am UTC](https://forums.unrealengine.com/t/how-to-exclude-debug-code-when-shipping-game/290643/4 "2014-08-11T11:49:12Z")

</div>

Are there any pre-processor defenitions for server / dedicated server as well?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [August 11, 2014, 12:31pm UTC](https://forums.unrealengine.com/t/how-to-exclude-debug-code-when-shipping-game/290643/5 "2014-08-11T12:31:51Z")

</div>

Yes UE\_SERVER if dedicated is compiled or WITH\_SERVER\_CODE if game should have server code at all

I just find this header file with most of defines

[https://github.com/EpicGames/UnrealEngine/blob/6c0afee5903072d1c20863d86f8decfffaab71f1/Engine/Source/Runtime/Core/Public/Misc/Build.h](https://github.com/EpicGames/UnrealEngine/blob/6c0afee5903072d1c20863d86f8decfffaab71f1/Engine/Source/Runtime/Core/Public/Misc/Build.h)
