# Debugmessage nullpointer?!

**URL:** <https://forums.unrealengine.com/t/debugmessage-nullpointer/331601>\
**Category:** Debugging, Optimization, & Profiling\
**Tags:** debug, unreal-engine, question\
**Created:** [September 9, 2015, 4:54pm UTC](https://forums.unrealengine.com/t/debugmessage-nullpointer/331601 "2015-09-09T16:54:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_3fac756c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3fac756c](https://forums.unrealengine.com/u/anonymous_user_3fac756c)\
**Post date:** [September 9, 2015, 4:54pm UTC](https://forums.unrealengine.com/t/debugmessage-nullpointer/331601/1 "2015-09-09T16:54:16Z")

</div>

Hello UE community,

i use this line in a method of a created Actor class, without it, everything works.

```
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("..."));

```

And I get this exception

```
Unhandled exception at 0x00007FFD5A87F5E4 (UE4Editor-Engine.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000778.

```

The compiling stop at the if command from UnrealEngine.cpp

```
/** Wrapper from int32 to uint64 */
void UEngine::AddOnScreenDebugMessage(int32 Key, float TimeToDisplay, FColor DisplayColor, const FString& DebugMessage)
{
	if (bEnableOnScreenDebugMessages == true)
	{
		AddOnScreenDebugMessage( (uint64)Key, TimeToDisplay, DisplayColor, DebugMessage);
	}
}

```

What I’m doing wrong?

Greetings!

---

<div class="post-metadata">

**Author:** ![Nsomnia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nsomnia](https://forums.unrealengine.com/u/Nsomnia)\
**Post date:** [September 9, 2015, 5:37pm UTC](https://forums.unrealengine.com/t/debugmessage-nullpointer/331601/2 "2015-09-09T17:37:15Z")

</div>

You need to have UE\_BUILD\_DEBUG as your build type for that line to work and

```
 #if UE_BUILD_DEBUG
     GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Red, "Some Message");
 #endif

```

would be the proper way

Generally messages to the screen are printed something like this

```
 UE_LOG(MyGame, Log, TEXT("Some Messsage") );

```

I highly reccomend reading Ramas post about debugging and printing messages here

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Hope this helps  
_Don’t forget to accept an answer that best clears your question up or answers it so when the community finds your question in the future via search/google they know exactly what you did to fix it/get it going._
