How to see what platform game is running on?

In c++, how do I see what platform the game is currently running on/compiled for?

1 Like

Do you mean something like this?

This is an extract of the ShooterGame. I guess you can use this if statement in your normal class too:

if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac))
			if (UEBuildConfiguration.bCompileSteamOSS == true)

		else if (Target.Platform == UnrealTargetPlatform.PS4)
        else if (Target.Platform == UnrealTargetPlatform.XboxOne)

I just took the whole part. Only the ifs are insteresting for your though.

Basically, C++ compile your source code to run on your machine Win/Mac, However, Inside the editor,You will have the ability to build your game to run on a different platform such as Android.

this means VS only build your game to run through your engine on Win/Mac platform, while The Editor itself who is responsible for building your final game to run on others platforms.

If I missed something, Please someone fixed it.

Best of luck

Thank you for the answer but that doesn’t answer my question. The question was: how do I, in code, see what platform my game is running on?

Hi ,

You can try to use this:


Also, if you want add some platform depended code you can use this macros


Hope it helps!

1 Like

Thanks that was just what i was looking for!

How do I check in C++ module, instead of UBT C#, if the target platform is x32 or x64?

Just like we do in .Build files, but I need this to load a dynamic DLL and need to check if the game built will be 64bits or not…

Found it, just need to use #PLATFORM_32BITS directive.