UnrealEngine4 – error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏,用“0”替换“#if/#elif
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
原文链接:https://www.stubbornhuang.com/944/
发布于:2020年10月26日 10:58:10
修改于:2023年06月26日 22:10:23
当前分类随机文章推荐
- UnrealEngine4 - 将TextureRenderTarget2D保存为图片 阅读2384次,点赞0次
- UnrealEngine4 - error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏,用“0”替换“#if/#elif 阅读5845次,点赞0次
- UnrealEngine4 - 关于UObject被自动GC垃圾回收的巨坑 阅读4500次,点赞0次
- UnrealEngine4 - 获取UE4最后的渲染缓存数据BackBuffer 阅读5943次,点赞4次
- UnrealEngine4 - 将FTexture2DRHIRef保存为图片 阅读3941次,点赞0次
- UnrealEngine4 - Can not find such file SceneRenderTargets.h,在UE4 C++层中正确的使用FSceneRenderTargets类 阅读3026次,点赞0次
- UnrealEngine4 - C++层打印信息到屏幕 阅读2841次,点赞0次
全站随机文章推荐
- Python - itertools.groupby使用详解 阅读1554次,点赞1次
- Python - BeautifulSoup的find()和findAll() 阅读3089次,点赞0次
- FFmpge - Ubuntu编译FFmpeg出现WARNING: pkg-config not found, library detection may fail警告 阅读6199次,点赞0次
- OpenCV - linux上编译出现undefined reference to cv::dnn::experimental_dnn错误 阅读2982次,点赞0次
- 资源分享 - OpenGL编程指南(原书第7版)- OpenGL红宝书高清扫描版PDF下载 阅读5450次,点赞1次
- 资源分享 - C和指针 高清PDF下载 阅读2854次,点赞0次
- C++ - C++类的特殊成员函数,析构函数,拷贝构造函数,移动构造函数,赋值运算符,移动赋值运算符介绍和基础语法 阅读1104次,点赞0次
- human3.6m : Download(数据集下载) 阅读28795次,点赞40次
- 资源分享 - Practical Algorithms for 3D Computer Graphics, Second Edition 英文高清PDF下载 阅读1779次,点赞1次
- FFmpeg - 修改视频帧率,将60FPS的视频修改为30FPS的视频,视频时间保持不变 阅读2081次,点赞1次
评论
169