UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
EngineVersionComparison.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6
7// Helper for UE_VERSION_NEWER_THAN and UE_VERSION_OLDER_THAN
8#define UE_GREATER_SORT(Value, ValueToBeGreaterThan, TieBreaker) \
9 (((Value) > (ValueToBeGreaterThan)) || (((Value) == (ValueToBeGreaterThan)) && (TieBreaker)))
10
11// Version comparison macro that is defined to true if the UE version is newer or equal than MajorVer.MinorVer.PatchVer
12// and false otherwise
13// (a typical use is for backward compatible code)
14#define UE_VERSION_NEWER_THAN_OR_EQUAL(MajorVersion, MinorVersion, PatchVersion)\
15 UE_GREATER_SORT(ENGINE_MAJOR_VERSION, MajorVersion, UE_GREATER_SORT(ENGINE_MINOR_VERSION, MinorVersion, UE_GREATER_SORT(ENGINE_PATCH_VERSION, PatchVersion, true)))
16
17// Version comparison macro that is defined to true if the UE version is newer than MajorVer.MinorVer.PatchVer and false otherwise
18// (a typical use is to alert integrators to revisit this code when upgrading to a new engine version)
19#define UE_VERSION_NEWER_THAN(MajorVersion, MinorVersion, PatchVersion) \
20 UE_GREATER_SORT(ENGINE_MAJOR_VERSION, MajorVersion, UE_GREATER_SORT(ENGINE_MINOR_VERSION, MinorVersion, UE_GREATER_SORT(ENGINE_PATCH_VERSION, PatchVersion, false)))
21
22// Version comparison macro that is defined to true if the UE version is older than MajorVer.MinorVer.PatchVer and false otherwise
23// (use when making code that needs to be compatible with older engine versions)
24#define UE_VERSION_OLDER_THAN(MajorVersion, MinorVersion, PatchVersion) \
25 UE_GREATER_SORT(MajorVersion, ENGINE_MAJOR_VERSION, UE_GREATER_SORT(MinorVersion, ENGINE_MINOR_VERSION, UE_GREATER_SORT(PatchVersion, ENGINE_PATCH_VERSION, false)))