C++ Transition Guide for 4.22

Any idea what’s happening with my project?

You’re in an infinite loop when trying to unpossess for some reason. If you changed something related to possession, I’d undo it.

An issue I ran into was that now you need to initialize variables in C++ in the order you declared them in the header

@BioXide
i am having a crash when I try to play my levels. Do you think That me not having variables initialized in the order they’re declared I. The header is part of the problem?

@cherking
It could in some cases, depends on compiler.

It seems to me Epic forces proper initialization order on

Done! Thank you.

I doubt that’s causing the crashes as not having them initialized properly will prevent compilation, best bet would be to run the debugger or check the logs to see the callstack

Hi guys. Any idea why it would happen when switched to 4.22 and VS2019? I’m attaching one static library to the project via build tool. It was compiling fine in 4.19 or 4.20 afair.

I don’t know what you mean by “via build tool”. I made some mistakes with static libraries myself when I first tried to link them, maybe you are linking them in the wrong way. Just in case, I inlcude a code of how I include my libs; This is from the “Client.Build.cs”



using UnrealBuildTool;
using System;

public class Client : ModuleRules
{
    public Client(ReadOnlyTargetRules Target) : base(Target)
    {
        System.String ThirdPartySharedLib;
        System.String ThirdPartyNOGS;

        System.Console.Write(@"Compiling for configuration: ");
        System.Console.WriteLine(Target.Configuration);
        System.Console.Write(@"ModuleDirectory: ");
        System.Console.WriteLine(ModuleDirectory);


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

        if (Target.Configuration == UnrealTargetConfiguration.Shipping)
        {
            ThirdPartySharedLib = System.IO.Path.GetFullPath(System.IO.Path.Combine(ModuleDirectory, "../../../SharedProjects/ClientServerShared/x64/Shipping/SHARED_DATA_LIBRARY.lib"));
            ThirdPartyNOGS = System.IO.Path.GetFullPath(System.IO.Path.Combine(ModuleDirectory, "../../../SharedProjects/NOGS/x64/Shipping/NOGLibrary.lib"));
            PublicAdditionalLibraries.Add(ThirdPartySharedLib);
            PublicAdditionalLibraries.Add(ThirdPartyNOGS);
            System.Console.WriteLine(@"Using Libraries: ");
            System.Console.WriteLine(ThirdPartySharedLib);
            System.Console.WriteLine(ThirdPartyNOGS);
        }
        if (Target.Configuration == UnrealTargetConfiguration.Development)
        {
...
        }
        if (Target.Configuration == UnrealTargetConfiguration.DebugGame)
        {
...
        }


    }
}




This is from 4.20 but it works in 4.22 too, except you have to add one line about the precompiled header which I dont remember exactly, but the build output will tell you exactly what to add, so you should be able to do that.

@Wallenstein thank you for your contribution.
I resolved the issue with my code, so I will describe here what I did.

The -Yu flag problem occurred because I recompiled my static library on VS2019 and apparently, the settings wasn’t the same. I had to turn off the pre-compiled headers when compiling my static library and the error went off.

It wasn’t the end of my problems. A new error occurred, which was something like:


 Error 815 error C1900: Il mismatch between 'P1' version '20100826' and 'P2' version '20080116'

Error 816 error LNK1257: code generation failed 

You can read about this error online, but it more or less about differences in saved parsed code (P1) in file vs generated code (P2).
I updated VS2019 to the newest version but it didn’t help. I compiled my static library and my UE4 project with same version of VS2019, so it was kinda confusing.

SOLUTION: I created a new blueprint project in UE4 editor and changed Edit->Editor Preferences->General->Source Code->Source Code Editor to Visual Studio 2019. Then I regenerated my main focus project’s solution and recompiled.

Good luck!

We get alot of *data member ‘XXX’ will be initialized after data member ‘YYY’ *. This was compiling fine in 4.21. Any idea how to fix it, hopefully without restructuring a ton of initialization.

You can add -Wno-reorder to ignore that error, but you should really just buckle down and fix it. Yes, it’s annoying, but the error is trying to save you some (potential) heartache.

Thanks for the Tipp. Just to be sure do I add the -Wno-reoder to the “Build startup project” Commandline Params in VS ?

Nope, just add it to the <Platform>Toolchain.cs, you’ll find a few -Wno<whatever> there.

Okay, but does that mean i need to have a custom Engine build for that ? or how would this work on a vanilla engine Project ? Also i cannot find a WindowToolChain.cs what is the right one for Win64 ?

VCToolChain.cs : Line 640-ish

And yes, you would need to do a custom Engine build. Again, another reason to just fix your initialization order instead. :slight_smile:

PlayAnimationTo changed to PlayAnimationTimeRange

For anybody that is looking to upgrade macros such as BEGIN_UNIFORM_BUFFER_STRUCT to do with shader parameters, see this commit https://github.com/EpicGames/UnrealEngine/commit/c72b7a33d8e1dba50863522615ff2b3d5a197e90

With Visual Studio 2019, in Editor configurations, I receive this include error.

1> [1/5] Module.SwarmInterface.cpp
1>D:\GitHub\UnrealEngine\Engine\Source\Editor\SwarmInterface\Private\SwarmInterface.cpp(21): fatal error C1083: Cannot open include file: ‘metahost.h’: No such file or directory

Not in Server or Client configurations.

Thanks for the heads up. This makes the understanding of the changes on several macros a lot easier. Cheers!