---
title: "Unreal c++常见问题"
author: "Perrin Yong"
author_profile: https://www.pystone.net/profile/
published_by: "Perrin Yong"
canonical: https://www.pystone.net/notes/unreal-cpp-common-issues/
type: note
content_role: unspecified
visibility: public
id_stability: rename-stable
source_path: "10-计算机、信息技术与工程/05-游戏图形与运行时/Unreal/Unreal c++常见问题.md"
content_hash: 54980d5f1e85022756ac3c8540787c8fd732263769f41b4061ecfc825d435f12
knowledge_version: 224c990773de.5fa8af6e39fa
site_commit: 224c990773de166d23a886306577dd90379529ce
notes_commit: 5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a
---
# Unreal c++常见问题

> 创建时间：2022/3/24 15:51

Unreal中使用Windows API：

D:\Windows Kits\10\include\10.0.20348.0\um\winnt.h(169): fatal error C1189: #error: "No Target Architecture"

![assets/0011 - Unreal c++常见问题__resource-001-40587206e91b.png](/media/5f1413dbdd2feb3d2046.png)

winnt.h这个头文件依赖windows.h这个头文件

但是Unreal又不能直接 #include "windows.h"，因为一些API有冲突，Unreal在windows的api上包了一层

Unreal用windows的api要用这种形式

![assets/0011 - Unreal c++常见问题__resource-002-e5bf7196fe8a.png](/media/92d4e940ac14997d0cd4.png)

<https://forums.unrealengine.com/t/how-to-include-windows-h/308000>

其他相关：<https://stackoverflow.com/questions/4845198/fatal-error-no-target-architecture-in-visual-studio>

## error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏，用“0”替换“#if/#elif”

一般为Windows中的宏和UE4冲突所致，需要用如下头文件包裹冲突的头文件：

#include "Windows/AllowWindowsPlatformTypes.h"

#include "Windows/PreWindowsApi.h"

#include "冲突的头文件"

#include "Windows/PostWindowsApi.h"

#include "Windows/HideWindowsPlatformTypes.h"

[TODO]Speed Up Shader Compiling

<https://www.techarthub.com/seven-tricks-to-speed-up-shader-compilation-in-unreal-engine-4/>

<https://forums.unrealengine.com/t/turn-off-auto-compile-shaders/353474>

<https://realtimevfx.com/t/ue4-compiling-shaders-is-super-slow/3163/27>

<https://medium.com/gamedev4k/reducing-shader-compile-time-for-unreal-engine-landscape-a7a6c7e2ca20>

程序里include过，VS中不报错，但是编译报错：无法解析外部符号。

很可能在Build文件里面，没有把 依赖的相关模块 添加进来。

![assets/0011 - Unreal c++常见问题__resource-003-d0b34070d60e.png](/media/209c3f71f09cbe6235d9.png)

unable to load module:

<https://blog.ch-wind.com/ue4-transition-log/>
