Cannot switch on Target.Platform

Hello,

I need to change some target files depending on what platform/os I am running. Therefore I am trying to switch on Target.Platform in my ProjectName.build.cs but this doesn’t seem to work.

switch (Target.Platform)
        {
            // 64-bit Windows
            case UnrealTargetPlatform.Win64:
                PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "accidental-noise-library", "build", "ANL", "x64", "ANL.lib"));
                break;

            // 32-bit Windows
            case UnrealTargetPlatform.Win32:
                PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "accidental-noise-library", "build", "ANL", "x86", "ANL.lib"));
                break;

            // Mac
            case UnrealTargetPlatform.Mac:
                PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "accidental-noise-library", "build", "ANL", "Universal", "libANL.a"));
                break;

            // Linux
            case UnrealTargetPlatform.Linux:
                PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "accidental-noise-library", "build", "ANL", "x64", "libANL.a"));
                break;

            default:
                break;
        }

This returns me an error saying the case-variable (in my case Target.Platform) has to be of the type bool, string, char or anything that can be null.
Does anyone know a fix to this?

Thanks in advance!

Regards,
Stefan

May be related to this change: Attention: Platform Changes Ahead! - Announcements - Unreal Engine Forums

Just replace switch with if…else

Your solution works perfectly fine. I haven’t paid attention to platform changes alot, and definetly didn’t realize UnrealTargetPlatform cannot be used in switches anymore. Here’s the new code replacing the switch statement:

if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            PublicAdditionalLibraries.Add(Path.Combine(ThirdPartyPath, "accidental-noise-library", "build", "ANL", "x64", "ANL.lib"));
        }

Thank you! :slight_smile: