Download

4.24 C++ Transition Guide

Dear Community,

For anyone wishing to share their notes or ask questions about the C++ upgrade to 4.24, feel free to do so here!

:heart:

Rama

The “Developer” module type is now deprecated

When compiling editor plugins for UE4.24 you will see one of these 2 warnings:

OR

The solution is to change “Developer” to “DeveloperTool”

Before 4.23:



    "Modules": 
        {
            "Name": "Debug",  [INDENT=3]**"Type": "Developer",**[/INDENT]
             "LoadingPhase": "PreDefault",
            "WhitelistPlatforms": 
                "Win64",
                "Win32",
                "Mac",
                "Linux"
            ]
        }
    ]


After 4.24:



    "Modules": 
        {
            "Name": "Debug",  [INDENT=3]**"Type": "DeveloperTool",**[/INDENT]
             "LoadingPhase": "PreDefault",
            "WhitelistPlatforms": 
                "Win64",
                "Win32",
                "Mac",
                "Linux"
            ]
        }
    ]


bFasterWithoutUnity is now deprecated

If you are using “bFasterWithoutUnity” in any of your *.Build.cs files, you will see this warning when compiling your modules:

It has now been deprecated in favor of “bUseUnity”.

Before 4.23:



// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class YourProject : ModuleRules
{
    public YourProject(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;[INDENT=2][SIZE=14px][SIZE=14px]**bFasterWithoutUnity = true;**[/SIZE][/SIZE][/INDENT]

        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });

        PrivateDependencyModuleNames.AddRange(new string] {  });
    }
}


After 4.24:



// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class YourProject : ModuleRules
{
    public YourProject(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;[INDENT=2][SIZE=14px][SIZE=14px]**bUseUnity = true;**[/SIZE][/SIZE][/INDENT]

        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });

        PrivateDependencyModuleNames.AddRange(new string] {  });
    }
}


"Upgrade" log messages and how to remove them

When upgrading from 4.23 to **4.24, **you may see these “Upgrade” log messages:



[Upgrade] Using backward-compatible build settings. The latest version of UE4 sets the following values by default, which may require code changes:
[Upgrade]     bLegacyPublicIncludePaths = false                 => Omits subfolders from public include paths to reduce compiler command line length. (Previously: true).
[Upgrade]     ShadowVariableWarningLevel = WarningLevel.Error   => Treats shadowed variable warnings as errors. (Previously: WarningLevel.Warning).
[Upgrade]     PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs   => Set in build.cs files to enables IWYU-style PCH model. See https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/IWYU/index.html. (Previously: PCHUsageMode.UseSharedPCHs).
[Upgrade] Suppress this message by setting 'DefaultBuildSettings = BuildSettingsVersion.V2;' in YourProjectEditor.Target.cs, and explicitly overriding settings that differ from the new defaults.


There is nothing you should worry about here, the engine is just telling you what’s been changed since the upgrade from 4.23. These are the new default settings for 4.24
However, if you want to remove these “Upgrade” log messages, then open your **YourProjectEditor.Target.cs **file and add the highlighted code below, like this:



// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

public class YourProjectEditorTarget : TargetRules
{
    public YourProjectEditorTarget( TargetInfo Target) : base(Target)
    {
        Type = TargetType.Editor;    **DefaultBuildSettings = BuildSettingsVersion.V2;**
 
        ExtraModuleNames.AddRange( new string] { "YourProject" } );
    }
}


Click save and rebuild your binaries. The next time you rebuild your binaries, these messages will no longer appear in the log.

And you can explicitly override one of those upgraded default settings, if you didn’t like the change.

For example:
You can change the default value of ShadowVariableWarningLevel to ‘Warning’ instead of the new default which is ‘Error’, like this:



// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

public class YourProjectEditorTarget : TargetRules
{
    public YourProjectEditorTarget( TargetInfo Target) : base(Target)
    {
        Type = TargetType.Editor;    DefaultBuildSettings = BuildSettingsVersion.V2;
  **   ShadowVariableWarningLevel = WarningLevel.Warning;**
 
        ExtraModuleNames.AddRange( new string] { "YourProject" } );
    }
}


hi,

It seems that if you don’t have a public/private folder hierarchy, you need to include the module name in the header include file.
Links to bLegacyPublicIncludePaths default settings. Did I miss something? Thanks,

Yah, needed to read this more carefully. When you “suppress” the message, you are then using those new settings.

I use subdirectories in my Public directory which blows up nicely when “suppressing” the message/using the new defaults.

I need some help updating a project that uses the Windows Bluetooth API (which works in 4.23). I’m using this header sandwich to get the necessary headers and libraries included:

#include “Windows/AllowWindowsPlatformTypes.h”
#include “Windows/prewindowsapi.h”

#include <stdio.h>
#include <windows.h>
#include <setupapi.h>
#include <devguid.h>
#include <regstr.h>
#include <bthdef.h>
#include <Bluetoothleapis.h>
#include <Objbase.h>
#pragma comment(lib, “SetupAPI”)
#pragma comment(lib, “BluetoothApis.lib”)

#include “Windows/PostWindowsApi.h”
#include “Windows/HideWindowsPlatformTypes.h”

The bluetooth identifiers such as BTH_LE_GATT_CHARACTERISTIC_VALUE are not found. I’m thinking BluetoothApis.lib isn’t being linked? Was the lib variable changed, or is there anything else I should check? Thanks!

Edit:
Figured it out. Turns out my macro definitions for _WIN32_WINNT and WINVER were reverted back to 0x601 (for WIndows 7) instead of persisting as 0x602 (Windows 8) in my previous build. I have to edit the intermediate files SharedPCH.Engine.h and Definitions.MyApp.h to change these macro definitions. Is there a better way to do this?

After migration to 4.24 i have following ensureMsgf:


LogOutputDevice: Error: Ensure condition failed: SyncGroup.GroupLeaderIndex == INDEX_NONE [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/Engine/Private/Animation/AnimInstanceProxy.cpp] [Line: 706] 
SyncGroup with GroupIndex=1 had a non -1 group leader index of 0 in asset CharacterMesh0

Did anyone encounter this problem?

After migrating from 4.23 to 4.24:

cannot open source file “#include JsonUtilities.h”

Changing the import like this:


#include "Runtime/JsonUtilities/Public/JsonUtilities.h"

Results in another error in JsonObjectWrapper.h


variable "FJsonObjectWrapper" is not a type name 

Anybody had this issue?

With the new build defaults, you need to literally include everything, so you need another include for JsonUtilities/Public/JsonObjectWrapper.h.

I noticed with BuildSettingsVersion.V2, a change in the way include paths work. I have projects that have the folder structure:



Source
-Actors
|-SomeActor.h
|-SomeActor.cpp
-Components
|-SomeComponent.h
|-SomeComponent.cpp


And I used to include files, for instance in SomeActor.cpp:


#include "Components/SomeComponent.h"

In 4.24 these includes could not be found without specifying the relative path:


#include "../Components/SomeComponent.h"

Unfortunately this broke Clang due to some UHT shenanigans. So the best path forward is to modify the build.cs file to specify all of my private include paths:



        PrivateIncludePaths.AddRange(
            new string]
            {
                "MyModuleName/Actors",
                "MyModuleName/Components",
            }
        );


And then just include the flat file with no path prefix:


#include "SomeComponent.h"

Hi,


warning C4996: 'AActor::GetComponentsByClass': Use one of the GetComponents implementations as appropriate Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.

Trying to convert this line to work on 4.24.1


auto EffectorComponents = GetOwner()->GetComponentsByClass(UEffectorComponent::StaticClass());

Any ideas?

error C4456: declaration of ‘class’ hides previous local declaration

Try:


TInlineComponentArray<UEffectorComponent*> EffectorComponents(GetOwner());

Please post your code that is triggering the compile error, not just the compile error itself, if you want us to be able to help you debug the matter :slight_smile:

:heart:

Rama

This looks like something that would be in your Anim Instance, your Anim BP asset, are you using sync groups?

UE4 Sync Groups

Does this ensure happen every time you restart editor / run PIE?

Does it happen if no characters are in the level and you just use the DefaultPawn?

“SyncGroup with GroupIndex=1 had a non -1 group leader index of 0 in asset CharacterMesh0”

Solution may be as simple as changing your sync group in whatever Anim BP is triggering this ensure.

:heart:

Rama

I had to change my


#include "AllowWindowsPlatformTypes.h"

into


#include "Windows/AllowWindowsPlatformTypes.h"


.

Simple fix, but slightly annoying.

20200217-16_01_02Clipboard.png

This is what shows up for me when loading my 4.22 project in 4.24.

ShooterGame works just fine with the same engine build, so I’ve been comparing them both to see if I can spot any differences but so far I haven’t found any.

Any clever ideas? I’ve deleted Intermediate/Binaries/DerivedDataCache as well but to no avail.

UncookedOnly is a new Project Type that came with 4.24. Likely your Project isn’t pointing to the right engine version (right click on your uproject and select “Switch Unreal Engine Version”), or you didn’t rebuild UHT when you downloaded the latest engine (if you’re building from source).

Thanks for replying, Matt.

They are pointing at the same version. Same path and same engine association ID. Same configuration too. See why I am confused? :slight_smile:

Will rebuild again!

**Edit: I deleted “Intermediate” and the x64/x86 folders inside “Binaries” and then rebuilt the Engine. Works now! **