# Can't display on Screen Debug Messages -- "GEngine is undeclared identifier"

**URL:** <https://forums.unrealengine.com/t/cant-display-on-screen-debug-messages-gengine-is-undeclared-identifier/27686>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 17, 2015, 11:05am UTC](https://forums.unrealengine.com/t/cant-display-on-screen-debug-messages-gengine-is-undeclared-identifier/27686 "2015-04-17T11:05:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_a636e19c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a636e19c](https://forums.unrealengine.com/u/anonymous_user_a636e19c)\
**Post date:** [April 17, 2015, 11:05am UTC](https://forums.unrealengine.com/t/cant-display-on-screen-debug-messages-gengine-is-undeclared-identifier/27686/1 "2015-04-17T11:05:51Z")

</div>

Hi There!

I’m quite a Beginner at C++, so my problem could be really trivial. I’m workin on a Mac using XCode.

I created an Actor, which detects if an object is passing through a Sphere. To see if this works out I tried the Quick tip print with a print() Makro found 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 — https://unrealcommunity.wiki/! You will be able to find content from...

So my Code looks as follows:

```auto

/ Fill out your copyright notice in the Description page of Project Settings.

#include "minimaladvvehicle.h"
#include "Lightswitchtry4.h"
#include "UnrealEngine.h"

//DirtyDebug Makro
#define print(text) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 1.5, FColor::Green,text)

//.. some Code

// ... Object passes through Sphere

print("Object passed")

```

I get a Warning saying “Use of undeclared Identifier GEngine.”

In the Documentation nothing is said about declaring the GEngine Identifier in the header file of the cpp where I use it.

I tried to include the UnrealEngine.h in the .cpp and the .h of my Actor but that didn’t helped.

Do I have to declare GEngine in the headerfile of my Actor? If so how do i do that?

I tried the following:

In the headerfile of my Actor I made the following delcaration:

```auto

//This is a bad idea
UPROPERTY()
UEngine* MyGEngine

```

and replaced GEngine with MyGEngine in the print Macro of the cpp.

The build was successful but the Engine crashed as soon as my Object reached the actor. (At least I know my actor works).  
So this can’t be right. The documentation and every C++ Tutorial Dealing with onScreen Debug Messages just uses the GEngine Identifier in the cpp file without any declaration in the headerfiles or somewhere else.

What am I missing? 😕

---

<div class="post-metadata">

**Author:** ![Martin\_Bean](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Martin\_Bean](https://forums.unrealengine.com/u/Martin_Bean)\
**Post date:** [April 17, 2015, 11:14am UTC](https://forums.unrealengine.com/t/cant-display-on-screen-debug-messages-gengine-is-undeclared-identifier/27686/2 "2015-04-17T11:14:20Z")

</div>

I think you need to include Engine.h

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a636e19c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a636e19c](https://forums.unrealengine.com/u/anonymous_user_a636e19c)\
**Post date:** [April 17, 2015, 11:57am UTC](https://forums.unrealengine.com/t/cant-display-on-screen-debug-messages-gengine-is-undeclared-identifier/27686/3 "2015-04-17T11:57:52Z")

</div>

Jepp. That solved the issue. Thanks! 🙂
