how to add C++ macro definition

Even I add Macro Definition in file MyProject.Target.cs

public override void SetupGlobalEnvironment(  
        TargetInfo Target,  
        ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,  
        ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration  

visual studio also shows warning:

how to add Definition in UE4 project?

can anybody help to resolve this problem?

I don’t know the answer to your question; I would tend to avoid strcpy() instead :slight_smile: There must be a better way…

Simply put this before the include and try this : #define _CRT_SECURE_NO_WARNINGS 1

if not work try other methods :
#ifdef _MSC_VER

Hope that help you.

thx~, but if define macro in code, it’s not convenient build for other platform.

thx~, but if define macro in code, it’s not convenient build for other platform.

I found the solution for latest UE4 version, define your macros in the constructor of MyProject.Build.cs ,like this:

using UnrealBuildTool;

public class MyProj : ModuleRules
    public MyProj(TargetInfo Target)
        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore" });
        PrivateDependencyModuleNames.AddRange(new string] { });


also can see example here:

This tbh, you shouldn’t be using unsafe string copying methods like that unless you’re willing to deal with the potential buffer overrun problems that naturally come from it. Is there also a reason why you’re using the C string functions instead of using Unreal’s FString?

becase I use a third lib which contains strcpy(), if avoid to use strcpy, I have to modify it’s code.

Thank you so much for sharing this. I got these warnings just by including Steam’s SDK and all those warnings polluting my squeaky-clean output window were driving me nuts :slight_smile: