4.15 C++ Transition Guide

Dear Community,

4.15 is here! Yay!

Post any questions or compile errors you figured out solutions for here!

Also any questions regarding changes between prior engine versions and 4.15 are welcome here


Skeletal Mesh

If you were using types defined in SkeletalMeshTypes.h, you may now need to include this file explicitly.

What is IWYU?

IWYU stands for “Include What You Use”, indicating that you have to manually include all headers for all engine code that you want to use rather than simply including large headers like one of my personal favorites, Engine.h, hee hee!

Here is the github commit where Epic’s Ben Marsh explains more:


**Disabling IWYU**

You can disable the new system by adding



```


bEnforceIWYU = false;


```



in your build.cs.

Why IWYU?

If you go through the work of finding and manually including all headers you need for the engine code you are using per file, then you stand the chance of seeing 20 to 50% improvement in your compile times :slight_smile:


**GEngine? ( * Sniff * )**

Epic's Ben Marsh (who was instrumental in arrival of IWYU) explains how to get access to GEngine here:
https://forums.unrealengine.com/showthread.php?137015-4-15-C-Transition-Guide&p=673109&viewfull=1#post673109

♥

UnrealBuildTool.UnrealBuildTool.GetAllServerPlatforms() doesn’t exist anymore.

If you have a dedicated server target (MyGameServer.Target.cs), I believe the correct way to define the platforms now is to annotate the class and delete the GetSupportedPlatforms method


[SupportedPlatforms(UnrealPlatformClass.Server)]
public class MyGameServerTarget : TargetRules
{
...
}


Haven’t tried it yet but I’m seeing the same changes on Epic’s commits at https://github.com/EpicGames/UnrealEngine/commit/6748a24fb192420b4ead6779e54a12b0001bfa8f

If you’re using TEnumAsByte as class member, remove it and use the Enums directly. If you were using .GetValue() for those in code, just remove it :slight_smile:

If you were using FAttenuationSettings in code, replace it with FSoundAttenuationSettings (It was renamed)

I’m on 4.13 and I can’t convert to 4.14 or 4.15
I only get a single error when compiling, and its from an engine file:
2b5da612d87221032dc26c1625c2b19e792dd555.jpeg

88328bbb05efc0ed43bb927ed447f3305f82f3dc.jpeg

The function it appears to be calling is here and seems to be in good order:
66c652aff2a7c62fab47762273f43870c34ccce2.jpeg

Whether updating to 4.14 or 4.15 I get the same error.

So what happens to our game header includes now? Does MyGame still need MyGame.h as the first include in every cpp file? What do I need to include in MyGame.h?

Yeah I’m also wondering what the header changes mean for existing C++ projects ??

Had a 4.14 project that used Paper2D and wouldn’t compile after upgrade, complaining about not knowing what a UPaperSpriteComponent was. Added include

#include “Paper2DClasses.h”

in my [project].h file and all was good :slight_smile:

Found tip here:
http://alienpixelstudios.com/2017/02/16/update-unreal-engine-4-14-4-15/

Looks like the engine now creates a .suppressed file which will force you to include what you use instead of letting your headers make use of Core.h or Engine.h as a whole; so if you use classes from different modules you have to include those module’s headers now, simply adding Engine.h won’t work.

UUserDefinedEnums have changed; there’s no more TArray<FName> DisplayNames, it’s now a TMap<FName,FText> DisplayNamesMap.
If you do DisplayNamesMap.GenerateValueArray() you get the stored Enum names from there.

I am trying to follow the “no Engine.h” paradigm so I removed the include to Engine.h from my MyGame.h file. However now I get weird errors, the first of which is in my interface:

2>/ActivationInterface.h(20): error C2065: ‘P_FINISH’: undeclared identifier
2>/ActivationInterface.h(20): error C2065: ‘P_NATIVE_BEGIN’: undeclared identifier
2>/ActivationInterface.h(20): error C2065: ‘P_NATIVE_END’: undeclared identifier
2>/ActivationInterface.h(20): error C2065: ‘Z_Param_Out_InbForcedActive’: undeclared identifier
2>/ActivationInterface.h(20): error C3861: ‘P_GET_UBOOL_REF’: identifier not found
2>/ActivationInterface.h(20): error C2065: ‘P_FINISH’: undeclared identifier
2>/ActivationInterface.h(20): error C2065: ‘P_NATIVE_BEGIN’: undeclared identifier
2>/ActivationInterface.h(20): error C2065: ‘P_NATIVE_END’: undeclared identifier
2>/ActivationInterface.h(20): error C2065: ‘Z_Param_Out_InbForcedActive’: undeclared identifier
2>/ActivationInterface.h(20): error C3861: ‘P_GET_UBOOL_REF’: identifier not found

Including Interface.h doesn’t help, and this error happens in the GENERATED_IINTERFACE_BODY().

Anyone got any idea?

I had a compile error saying that UE4EditorServices couldn’t be compiled because it does not run on Win64 systems + I had no rights to run Build.bat.
Edit: Fixed by cleaning solution and rebuilding it.

To use “GEditor->” you now have to include “Editor.h” ( tested in plugin )

I also noticed this during compilation: Skipping MfMedia (requires WINVER >= 0x0601, but WINVER is 0x0601) well… it says WINVER greater or equal to 0x0601 so why skip?

I understand the logic of the use of PCH file has been completely abandoned. Is it possible to revert to the old rules for the project? I would like to use the PCH file and do not add a number of .h files in each .h file.

Now in each elementary .h file must be something like this:

#include “CoreMinimal.h”
#include “UObject/Object.h”
#include “UObject/WeakObjectPtr.h”

Vehicles have been moved to a plugin, now you have to include “PhysXVehicles” in your build.cs.

Substance plugin (from 4.14) has many compilation errors in 4.15 due to new rules for .h files

bEnforceIWYU = true enables warnings or errors about violations of these rules
bEnforceIWYU = false by defaults and there are no warnings or errors in our projects

Thank you. One less error!

Change 3215333 on 2016/11/30 by Ben.Marsh

UBT: Replace the GetSupportedPlatforms() callback on TargetRules with a SupportedPlatforms attribute. Since a TargetRules object can only be instantiated with an actual platform, it doesn't make sense for it to be an instance method.

It seems trying to play Sequencer movies now cause errors



build.cs
PublicDependencyModuleNames.AddRange(new string] { ..., "LevelSequence" });

.h
UPROPERTY(EditAnywhere, Category = "AKQ") ALevelSequenceActor* Cutscene;

.cpp
#include "LevelSequenceActor.h"
{
Cutscene->SequencePlayer->Play();
}


Now gives “Unresolved external symbols” errors anywhere Cutscene->SequencePlayer->Play(); (or Stop, Pause, etc) was used.
So putting Sequencer into cpp still works, but playing it in any way causes the errors.

Commenting those out fixes it, but now how can we Play/Pause/Stop sequencer from within cpp?

Edit: Fixed by adding “MovieScene” to PrivateDependencyModuleNames in build.cs
Thanks @campd

Is this what is now generated when you create a new code project?

Is this what is now generated when you create a new code project?
[/QUOTE]

No. It is for IWYU case only (engine plugins or projects with enabled IWYU).

A few Gameplay Abilities related things that I found:

Since this has been moved to a component, make sure to add GameplayAbilities to your plugin list in the .uproject file, otherwise you’ll get a dll error (if porting a project that was already using abilities).

Also if you are using static gameplay cue notifies, there is an issue if they have a “PlaySoundAtLocation” node in the blueprint. Something to do with how things are loaded, causes an engine level freeze.
The workaround I found here is to add


	UGameplayCueManager* CueManager = UAbilitySystemGlobals::Get().GetGameplayCueManager();
	CueManager->InitializeEditorObjectLibrary();


to your StartupModule code, to force an init on the cues. Then you can open static gameplay cue notifies without hanging.