Is there Unreal Egnine version macro definition?

For some reason, I have to make my project runs for both UE 4.11 and UE 4.12.

I’m looking for some version macro for UE4, like UE_VERSION listed below.

void Attach(USceneComponent* component, USceneComponent* parent)
{
#if UE_VERSION == 41100
	component->AttachTo(parent); // UE 4.11
#elif UE_VERSION == 41200
	component->AttachToComponent(parent, FAttachmentTransformRules::KeepRelativeTransform); // UE 4.12
#endif
}

Is there any macro define in UE4 that I can use?

Yes, in Version.h you have ENGINE_MAJOR_VERSION, ENGINE_MINOR_VERSION and ENGINE_PATCH_VERSION.

Franco

1 Like

I had to use this line:
#include “Runtime/Launch/Resources/Version.h”

1 Like

- Allow myself to bump it as it is the first result on Google and I keep searching for it -

C++

Option 1:

#include "Misc/EngineVersionComparison.h"

// Can use
UE_VERSION_NEWER_THAN
UE_VERSION_OLDER_THAN

// Example:
#if UE_VERSION_NEWER_THAN(5, 3, 0)
    // 5.3.0 and up only code
#endif

#if UE_VERSION_OLDER_THAN(5, 3, 0)
    // 5.3.0- only code
#endif

Option2:

#include "Runtime/Launch/Resources/Version.h"

// Then can access the following macros: 
ENGINE_MAJOR_VERSION
ENGINE_MINOR_VERSION
ENGINE_PATCH_VERSION

C#

#if UE_5_3_OR_LATER
    // 5.3 and up C# code
#endif