1. 程式人生 > >ue4 呼叫windows庫函式報錯 error C2872: error C2872: “DWORD”: 不明確的符號

ue4 呼叫windows庫函式報錯 error C2872: error C2872: “DWORD”: 不明確的符號

當在虛幻引擎(ue4)中呼叫 windows api 是 會出現一下類似的錯誤時:

1>C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcasync.h(114): error C2872: “DWORD”: 不明確的符號
1>  C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h(156): note: 可能是“unsigned long DWORD”
1>  c:\epic games\ue_4.14\engine\source\runtime\core\public\Misc/DisableOldUETypes.h(34): note: 或  “DoNotUseOldUE4Type::DWORD”
1>C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcasync.h(126): error C2872: “UINT”: 不明確的符號
1>  C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h(177): note: 可能是“unsigned int UINT”
1>  c:\epic games\ue_4.14\engine\source\runtime\core\public\Misc/DisableOldUETypes.h(31): note: 或  “DoNotUseOldUE4Type::UINT”

可以用下面的方法解決:

#include "AllowWindowsPlatformTypes.h"
#include <windows.h>
#include <comdef.h>
#include <WbemIdl.h>
#include "HideWindowsPlatformTypes.h"

-----------------

也就是如果要引用帶有windows.h,需要在前面加上AllowWindowsPlatfromTypes.h,後面加上HideWindowPlatformTypes.h檔案