UnrealEngine4 – error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏,用“0”替换“#if/#elif
本文作者:StubbornHuang
版权声明:本文为站长原创文章,如果转载请注明原文链接!
原文标题:UnrealEngine4 – error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏,用“0”替换“#if/#elif
原文链接:https://www.stubbornhuang.com/944/
发布于:2020年10月26日 10:58:10
修改于:2020年10月31日 16:41:33

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"
当前分类随机文章推荐
- UnrealEngine4 - C++层打印信息到屏幕 阅读1423次,点赞0次
- UnrealEngine4 - 将FTexture2DRHIRef保存为图片 阅读2025次,点赞0次
- UnrealEngine4 - 关于UObject被自动GC垃圾回收的巨坑 阅读2716次,点赞0次
- UnrealEngine4 - Can not find such file SceneRenderTargets.h,在UE4 C++层中正确的使用FSceneRenderTargets类 阅读1940次,点赞0次
- UnrealEngine4 - 获取UE4最后的渲染缓存数据BackBuffer 阅读2931次,点赞2次
- UnrealEngine4 - error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏,用“0”替换“#if/#elif 阅读2824次,点赞0次
- UnrealEngine4 - 将TextureRenderTarget2D保存为图片 阅读1107次,点赞0次
全站随机文章推荐
- 资源分享 - Vulkan Cookbook - Work through recipes to unlock the full potential of the next generation graphics API-Vulkan 英文高清PDF下载 阅读1005次,点赞0次
- Chrome中播放时视频编码为.h264和音频编码为acc,采样率为48000,双通道的视频文件时音画不同步 阅读2884次,点赞1次
- 资源分享 - GPU Pro 360 - Guide to Mobile Devices 英文高清PDF下载 阅读1335次,点赞0次
- 资源分享 - Mathematics for Computer Graphics , Fifth Edition 英文高清PDF下载 阅读550次,点赞0次
- 资源分享 - Vulkan Programming Guide - The Official Guide to Learning Vulkan 英文高清PDF下载 阅读1259次,点赞0次
- 资源分享 - 计算机动画算法与技术,Computer Animation - Algorithms and Techniques(Second Edition)中文版PDF下载 阅读136次,点赞0次
- WordPress - 修复WordPress升级5.1之后版本评论回复按钮失效不跳转以及不弹出评论框的问题 阅读184次,点赞0次
- 资源分享 - Game AI Pro - Collected Wisdom of Game AI Professionals 英文高清PDF下载 阅读852次,点赞0次
- 资源分享 - Digital Lighting & Rendering , Third Edition 英文高清PDF下载 阅读307次,点赞0次
- 计算几何 - 二维笛卡尔坐标系中,计算二维点绕任意中心点旋转任意角度的结果 阅读152次,点赞0次
评论
144