4.15 C++ Transition Guide

Any reason you don’t use UE_LOG()?

That’s a tough question really, I’m afraid you’ll have to sit through some training wheels to get to the good stuff. Look at Epic’s official C++ tutorial video playlist and skim through the boring stuff.

I do; but I need debug messages too.

A bit off-topic, but what does the GEngine logging have that UE_LOG doesn’t? I never used it actually.

I am addicted to on-screen debug messages with color-coded level of importance since I put my hands on BlitzBasic back in 2001;
I m.u.s.t use them, I can’t help it :stuck_out_tongue:
It’s my little weird ritual…

Err we got crashed from IOnlineSubsystem in 4.15.

Whenever we call the new CreateSession() with the the FUniqueNetId, the engine crash. It said the array is out of bound.
CreateSession() with the old int32 HostingPlayerNum also produce the same error and crash the engine.

We follow everything by the book closely and didn’t have any problem with old versions.

Anyone has any clue to this?


Dear Community,

Thank you to everyone in this thread for sharing your solutions!

So no one has found solution for GEngine yet + Debug Messages?!

I can’t code without my onscreen debug messages…



Nothing about this yet I guess.
For now I’m just going to keep on including Engine.h

Solution for GEngine in 4.15+ :heart: Rama

If you look in EngineGlobals.h, GEngine is an extern ptr, you can make your own!

I chose to use a namespaced extern ptr :slight_smile:


namespace YourCore
	extern UEngine* Engine;


namespace YourCore
	UEngine* Engine = nullptr;

**Role of GameInstance::GetEngine()**

The Outer of GameInstance is the current engine, so it will return the correct GEngine regardless of PIE, standalone, packaged game, etc!



void UYourGameInstance::Init()
	//Gives proper pointer in editor PIE, standalone, and packaged game!
	YourCore::Engine = GetEngine(); //CastChecked<UEngine>(GetOuter());


Hot Reload

Because my custom Engine ptr is at project level (in YourGame.h) and not the engine level, it gets nulled on hot reload.

My solution for this was to re-set the ptr by responding to the OnHotReload() delegate. (GetWorld()->GetGameInstance()->GetEngine())

void AYourActorClass::OnHotReload(bool bWasTriggeredAutomatically)
	//Re-Set my custom engine ptr!
	UWorld* World = GetWorld();
	UGameInstance* GI = World->GetGameInstance();
		YourCore::Engine = GI->GetEngine();

See NavigationSystem.h and .cpp for the full Hot Reload implementation, I made my own OnHotReload in my chosen actor class to reset the ptr after a hot reload.

Result: Got my own GEngine now, and Hot Reload doesnt even crash! Woohooo!




Oh this is super cool!
I gonna try it next monday, thanks!

Let me know how it goes!

Have fun today!



Hey Rama, thanks for the tip!

That being said, since I never use on-screen debugging, I should be able to get by by just using ->GetWorld() on UObject’s instead of GEngine->GetWorldFromContextObject() (Which is the only use-case I ever had of GEngine).

Guys, can someone tell me, are you actually getting a compiler warning/error about including Engine.h? I’ve added the following to my Build.cs files:

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
bEnforceIWYU = true;

I’m getting the new behaviour (no module PCH used) but I can still include Engine.h and use GEngine without issue. Wondering what I’m missing?

Also, confused by Rama’s solution. The GEngine pointer is declared in the same header as the UEngine class, so if you can’t include that header, then creating another extern declaration won’t help because without the class definition, you can’t access any members or methods anyway. The fact there are two Engine.h files doesn’t help much (Engine/Classes/Engine.h and Engine/Public/Engine.h). The former includes the class and GEngine, but it’s the latter that is the monolithic header which presumably we’re no longer supposed to be including.

Hi all, I have a similar issue to earlier in this thread, when i drop my plugins into a 4.15 project, visual studio cannot find any of the headers. Adding bEnforceIWYU = false; should help, right? but it doesn’t. Do I need to rewrite every class to upgrade? Ug.

EDIT. Yes, yes i do. :slight_smile: rebuilding the plugins without the PCH is the way forward.

We’re getting the check() in DataChannel.cpp:1523 halting our game now when we remove some of our objects from the scene. The ‘bKeepReplicators’ input param is being set to true by (updated in 4.15) line 1707.

Any idea what use case this change was meant to fix and what we’re doing wrong ?


You are right.
I did include Engine/Engine.h instead of the public Engine.h and I got no warnings!

I also can include the public Engine.h even if I set bEnforceIWYU too; maybe it’s not fully enforcing us for now :confused:


So I’ve ended up doing this; seems to work:

#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "UObject/WeakObjectPtr.h"
#include "Runtime/Engine/Classes/Engine/Engine.h"

Yeah, it’s a little embarrasing the number of things we refer to as “Engine”. It’s all legacy, unfortunately. There’s the top-level Engine folder, then the engine module, then the giant Engine/Public/Engine.h header, then there’s the definition of UEngine and GEngine in Engine/Classes/Engine/Engine.h.

The way to include the latter (definition of GEngine and UEngine) is to #include “Engine/Engine.h”.

@kamrann && [MENTION=434]BrUnO XaVIeR[/MENTION]

Thanks for sharing your further research, I’ve updated my original post with Ben’s confirmation of the solution you found :slight_smile:

You’re welcome, and hi @DamirH ! So nice to have you around!

Thank you for explaining Ben!



Oh my this sounds serious!

I hope Epic sees this :slight_smile:


Has anyone ran into this? I only get this in a packaged build…

The only place im using std is with my sql wrapper and i need the vectors as part of the call back to the sqlite lib.

Is IWYU meant for gameplay code? Everything I see is referencing engine and plugin/module compile times, but nothing specifically referencing code outside that scope. Is it worth going through the trouble and converting my project to IWYU?