问题
Trying to integrate the Directx toolkit into my game. I followed the steps here:
https://github.com/Microsoft/DirectXTK/wiki/Adding-the-DirectX-Tool-Kit
and everything went great. When trying to include one of the headers (SpriteFont.h) I get these errors:
I've refactored the project to 8.1 to match my game, and rebuilt the imported project and it works great. It's when rebuilding my project that I get these error.
(I've already made sure windows.h is being included before my directx headers.
Help!
回答1:
More than likely you are mixing the legacy DirectX SDK headers with the Windows 8.x SDK headers and mixing the old DXGI headers with new ones. As detailed on MSDN, if you want to mix the old DirectX SDK with the Windows 8.x SDK, you need to invert the traditional include path order.
Don't use this:
<IncludePath>$(DXSDK_DIR)Include$(IncludePath);</IncludePath>
<LibraryPath>$(DXSDK_DIR)Lib\x86$(LibraryPath);</LibraryPath>
<LibraryPath>$(DXSDK_DIR)Lib\x64;$(LibraryPath);</LibraryPath>
Use this:
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include</IncludePath>
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x86</LibraryPath>
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x64;</LibraryPath>
There are also some #include
tricks if you are using older stuff like D3DX
headers which can implicitly pick up the old headers.
Ideally you should remove all use of the legacy DirectX SDK paths, but if you want to use XAudio on Windows 7 you need to continue to use it. See the wiki for details.
回答2:
you can probably try to #include "SpriteFont.h" in your .cpp file instead of your .h header file. I solved this problem in this way.
来源:https://stackoverflow.com/questions/38174893/syntax-error-identifier-dxgi-rgba-in-file-dxgi1-2-h