1 错误原因

出现这种错误,一般为Windows中的宏与UE4冲突所导致。

2 解决方法

2.1 修改插件xxxx.Build.cs

在插件xxxx.Build.cs中加入以下代码:

bEnableUndefinedIdentifierWarnings = false;

完整插件xxxx.Build.cs代码示例:

// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class TwowaySocketPlugin : ModuleRules
{
    public TwowaySocketPlugin(ReadOnlyTargetRules Target) : base(Target)
    {
        bEnableUndefinedIdentifierWarnings = false;

        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

        PublicIncludePaths.AddRange(
            new string[] {
                // ... add public include paths required here ...
            }
            );


        PrivateIncludePaths.AddRange(
            new string[] {
                // ... add other private include paths required here ...
            }
            );


        PublicDependencyModuleNames.AddRange(
            new string[]
            {
                "Core",
                // ... add other public dependencies that you statically link with here ...
            }
            );


        PrivateDependencyModuleNames.AddRange(
            new string[]
            {
                "CoreUObject",
                "Engine",
                "Slate",
                "SlateCore",
                // ... add private dependencies that you statically link with here ...  
            }
            );


        DynamicallyLoadedModuleNames.AddRange(
            new string[]
            {
                // ... add any modules that your module loads dynamically here ...
            }
            );
    }
}

2.2 使用UE4包含机制解决

使用以下代码包含起冲突的Windows相关的头文件:

#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"

// 包含起冲突的头文件,例如
#include <windows.h>

#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"

当前分类随机文章推荐

全站随机文章推荐

关于本站站长 StubbornHuang
UnrealEngine4 – error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏,用“0”替换“#if/#elif-StubbornHuang Blog纵使晴明无雨色,入云深处亦沾衣。