{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/unreal-cpp-common-issues/",
  "atlas": "https://www.pystone.net/?node=unreal-cpp-common-issues#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/unreal-cpp-common-issues.md",
  "context": "https://www.pystone.net/notes/unreal-cpp-common-issues.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:unreal-cpp-common-issues",
  "slug": "unreal-cpp-common-issues",
  "title": "Unreal c++常见问题",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "Unreal c++常见问题",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "54980d5f1e85022756ac3c8540787c8fd732263769f41b4061ecfc825d435f12",
  "assets": [
    {
      "reference": "assets/0011 - Unreal c++常见问题__resource-001-40587206e91b.png",
      "url": "/media/5f1413dbdd2feb3d2046.png",
      "mediaType": "image/png",
      "contentHash": "5f1413dbdd2feb3d20462a82bcd8ddffc36c81738aea356fb484a8c6a30c03c0",
      "byteLength": 28548,
      "width": 465,
      "height": 216
    },
    {
      "reference": "assets/0011 - Unreal c++常见问题__resource-002-e5bf7196fe8a.png",
      "url": "/media/92d4e940ac14997d0cd4.png",
      "mediaType": "image/png",
      "contentHash": "92d4e940ac14997d0cd401c4e983b90622ec55a23188db587dc755f9b06b3877",
      "byteLength": 16440,
      "width": 421,
      "height": 169
    },
    {
      "reference": "assets/0011 - Unreal c++常见问题__resource-003-d0b34070d60e.png",
      "url": "/media/209c3f71f09cbe6235d9.png",
      "mediaType": "image/png",
      "contentHash": "209c3f71f09cbe6235d923b82c43cfbf4ce8527fd6a99460199322a689fc9bb0",
      "byteLength": 21833,
      "width": 412,
      "height": 358
    }
  ],
  "headings": [
    {
      "depth": 1,
      "text": "Unreal c++常见问题",
      "anchor": "unreal-c常见问题",
      "citation": "https://www.pystone.net/notes/unreal-cpp-common-issues/#unreal-c%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98"
    },
    {
      "depth": 2,
      "text": "error C4668: 没有将“WIN32WINNTWIN10TH2”定义为预处理器宏，用“0”替换“#if/#elif”",
      "anchor": "error-c4668-没有将win32winntwin10th2定义为预处理器宏用0替换ifelif",
      "citation": "https://www.pystone.net/notes/unreal-cpp-common-issues/#error-c4668-%E6%B2%A1%E6%9C%89%E5%B0%86win32winntwin10th2%E5%AE%9A%E4%B9%89%E4%B8%BA%E9%A2%84%E5%A4%84%E7%90%86%E5%99%A8%E5%AE%8F%E7%94%A80%E6%9B%BF%E6%8D%A2ifelif"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "Unreal中的“Unreal c++常见问题”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#unreal"
    }
  ],
  "contentMarkdown": "# Unreal c++常见问题\n\n> 创建时间：2022/3/24 15:51\n\nUnreal中使用Windows API：\n\nD:\\Windows Kits\\10\\include\\10.0.20348.0\\um\\winnt.h(169): fatal error C1189: #error: \"No Target Architecture\"\n\n![](assets/0011 - Unreal c++常见问题__resource-001-40587206e91b.png)\n\nwinnt.h这个头文件依赖windows.h这个头文件\n\n但是Unreal又不能直接 #include \"windows.h\"，因为一些API有冲突，Unreal在windows的api上包了一层\n\nUnreal用windows的api要用这种形式\n\n![](assets/0011 - Unreal c++常见问题__resource-002-e5bf7196fe8a.png)\n\n<https://forums.unrealengine.com/t/how-to-include-windows-h/308000>\n\n其他相关：<https://stackoverflow.com/questions/4845198/fatal-error-no-target-architecture-in-visual-studio>\n\n## error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏，用“0”替换“#if/#elif”\n\n一般为Windows中的宏和UE4冲突所致，需要用如下头文件包裹冲突的头文件：\n\n#include \"Windows/AllowWindowsPlatformTypes.h\"\n\n#include \"Windows/PreWindowsApi.h\"\n\n#include \"冲突的头文件\"\n\n#include \"Windows/PostWindowsApi.h\"\n\n#include \"Windows/HideWindowsPlatformTypes.h\"\n\n[TODO]Speed Up Shader Compiling\n\n<https://www.techarthub.com/seven-tricks-to-speed-up-shader-compilation-in-unreal-engine-4/>\n\n<https://forums.unrealengine.com/t/turn-off-auto-compile-shaders/353474>\n\n<https://realtimevfx.com/t/ue4-compiling-shaders-is-super-slow/3163/27>\n\n<https://medium.com/gamedev4k/reducing-shader-compile-time-for-unreal-engine-landscape-a7a6c7e2ca20>\n\n程序里include过，VS中不报错，但是编译报错：无法解析外部符号。\n\n很可能在Build文件里面，没有把 依赖的相关模块 添加进来。\n\n![](assets/0011 - Unreal c++常见问题__resource-003-d0b34070d60e.png)\n\nunable to load module:\n\n<https://blog.ch-wind.com/ue4-transition-log/>\n"
}
