Hi,
Updating project to work with UE5.7.4 and run into preprocessor defines in .target.cs & .build.cs files.
e.g.
.build.cs
if (Target.Configuration != UnrealTargetConfiguration.Shipping)
{
PublicDefinitions.Add(“WITH_STEAM_ACHIEVEMENTS_DEV=1”);
}
even adding: PublicDefinitions.Add(“WITH_STEAM_ACHIEVEMENTS_DEV=0”); doesn’t work
getting when building.
>M:\Projects\PBP\P1_UE5.7_Int\P1Game\Source\P1Game\Private\Utility\PBPFunctionLibrary.cpp(1117,5): error C4668: ‘WITH_STEAM_ACHIEVEMENTS_DEV’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’
1>#if WITH_STEAM_ACHIEVEMENTS_DEV
All fine with 5.6 when preprocessor not defined, is this a change in UE or MSVC?
sing Visual Studio 2022 14.44.35226 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.44.35207) and Windows 10.0.22621.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Determining max actions to execute in parallel (24 physical cores, 32 logical cores)
Thanks,
Simon
[Attachment Removed]
Hi,
This is probably a MSVC change, but as far as I remember it was never good to have a #if SOMETHING where SOMETHING is not defined. But this should define the macro all the time in your build.cs file for a given module.
PublicDefinitions.Add($"WITH_STEAM_ACHIEVEMENTS_DEV={(Target.Configuration != UnrealTargetConfiguration.Shipping ? "1" : "0")}");If you only ever use this in your .cpp of this module, you should use PrivateDefinitions instead:
PrivateDefinitions.Add($"WITH_STEAM_ACHIEVEMENTS_DEV={(Target.Configuration != UnrealTargetConfiguration.Shipping ? "1" : "0")}");If you need this definitions globally. Put it your target.cs as global
GlobalDefinitions.Add($"WITH_STEAM_ACHIEVEMENTS_DEV={(Target.Configuration != UnrealTargetConfiguration.Shipping ? "1" : "0")}");The engine generates .rsp file that you can look for the .cpp that is compiled. (I used Everything.exe to search my disk). So it looks like the engine was compiling PBPFunctionLibrary.cpp, you should find a PBPFunctionLibrary.rsp somewhere in the Intermediate directory for the platform. Either you put your PublicDefinitions in the wrong module or it needs to be put in several modules (or global).
The engine also use a fallback in the code itself. The following pattern is often used in configuration headers:
#ifndef WITH_STEAM_ACHIEVEMENTS_DEV
#defined WITH_STEAM_ACHIEVEMENTS_DEV !UE_BUILD_SHIPPING
#endif
Regards,
Patrick
[Attachment Removed]
Hey Patrick,
Yep a change in MSVC. The engineer added so #defines are created either ‘1’ or ‘0’.
All seems to be good for now 
Thanks,
Simon
[Attachment Removed]