Announcement

Collapse
No announcement yet.

4.24 C++ Transition Guide

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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!



    Rama
    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    ♥ Rama

    #2
    The "Developer" module type is now deprecated

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

    WARNING: The 'Developer' module type has been deprecated in 4.24. Use 'DeveloperTool' for modules that can be loaded by game/client/server targets in non-shipping configurations, or 'UncookedOnly' for modules that should only be loaded by uncooked editor and program targets (eg. modules containing blueprint nodes)
    OR

    Warning: The 'Developer' module type has been deprecated in 4.24.


    The solution is to change "Developer" to "DeveloperTool"

    Before 4.23:

    Code:
        "Modules": [
            {
                "Name": "Debug",
    "Type": "Developer",
    "LoadingPhase": "PreDefault", "WhitelistPlatforms": [ "Win64", "Win32", "Mac", "Linux" ] } ]
    After 4.24:

    Code:
        "Modules": [
            {
                "Name": "Debug",
    "Type": "DeveloperTool",
    "LoadingPhase": "PreDefault", "WhitelistPlatforms": [ "Win64", "Win32", "Mac", "Linux" ] } ]

    Comment


      #3
      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:

      Warning CS0618: 'UnrealBuildTool.ModuleRules.bFasterWithoutUnity' is obsolete: 'bFasterWithoutUnity has been deprecated in favor of setting 'bUseUnity' on a per module basis in BuildConfiguration'
      It has now been deprecated in favor of "bUseUnity".



      Before 4.23:

      Code:
      // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
      
      using UnrealBuildTool;
      
      public class YourProject : ModuleRules
      {
          public YourProject(ReadOnlyTargetRules Target) : base(Target)
          {
              PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
      bFasterWithoutUnity = true;
      PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); PrivateDependencyModuleNames.AddRange(new string[] { }); } }


      After 4.24:

      Code:
      // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
      
      using UnrealBuildTool;
      
      public class YourProject : ModuleRules
      {
          public YourProject(ReadOnlyTargetRules Target) : base(Target)
          {
              PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
      bUseUnity = true;
      PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); PrivateDependencyModuleNames.AddRange(new string[] { }); } }

      Comment


        #4
        "Upgrade" log messages and how to remove them

        When upgrading from 4.23 to 4.24, you may see these "Upgrade" log messages:

        Code:
        [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:

        Code:
        // 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:

        Code:
        // 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" } ); } }

        Comment


          #5
          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,

          Comment


            #6
            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.

            Comment


              #7
              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?
              Last edited by vle07; 01-06-2020, 06:42 PM.

              Comment


                #8
                After migration to 4.24 i have following ensureMsgf:

                Code:
                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?

                Comment


                  #9
                  After migrating from 4.23 to 4.24:

                  cannot open source file "#include JsonUtilities.h"

                  Changing the import like this:
                  Code:
                  #include "Runtime/JsonUtilities/Public/JsonUtilities.h"
                  Results in another error in JsonObjectWrapper.h
                  Code:
                  variable "FJsonObjectWrapper" is not a type name
                  Anybody had this issue?

                  Comment


                    #10
                    Originally posted by ExperienciaUmbra View Post
                    After migrating from 4.23 to 4.24:

                    Results in another error in JsonObjectWrapper.h
                    Code:
                    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.
                    Dev Blog http://www.error454.com

                    Comment


                      #11
                      I noticed with BuildSettingsVersion.V2, a change in the way include paths work. I have projects that have the folder structure:
                      Code:
                      Source
                      -Actors
                      |-SomeActor.h
                      |-SomeActor.cpp
                      -Components
                      |-SomeComponent.h
                      |-SomeComponent.cpp
                      And I used to include files, for instance in SomeActor.cpp:
                      Code:
                      #include "Components/SomeComponent.h"
                      In 4.24 these includes could not be found without specifying the relative path:
                      Code:
                      #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:
                      Code:
                              PrivateIncludePaths.AddRange(
                                  new string[]
                                  {
                                      "MyModuleName/Actors",
                                      "MyModuleName/Components",
                                  }
                              );
                      And then just include the flat file with no path prefix:
                      Code:
                      #include "SomeComponent.h"
                      Dev Blog http://www.error454.com

                      Comment


                        #12
                        Hi,

                        Code:
                        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

                        Code:
                        auto EffectorComponents = GetOwner()->GetComponentsByClass(UEffectorComponent::StaticClass());
                        Any ideas?

                        Comment


                          #13
                          error C4456: declaration of 'class' hides previous local declaration

                          Comment


                            #14
                            Originally posted by Thumper View Post
                            Hi,

                            Code:
                            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

                            Code:
                            auto EffectorComponents = GetOwner()->GetComponentsByClass(UEffectorComponent::StaticClass());
                            Any ideas?
                            Try:
                            Code:
                            TInlineComponentArray<UEffectorComponent*> EffectorComponents(GetOwner());
                            Dev Blog http://www.error454.com

                            Comment


                              #15
                              Originally posted by IppolitoGermer View Post
                              error C4456: declaration of 'class' hides previous local declaration
                              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



                              Rama
                              UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                              ♥ Rama

                              Comment

                              Working...
                              X