How to exclude debug code when shipping game

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.

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

3 Likes

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

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

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

1 Like