问题描述
我在使用Visual Studio 2012的Windows 7上。
I'm on windows 7 using Visual Studio 2012.
编译时,我收到很多由winerror.h和dxgi.h引起的宏重新定义警告, dxgitype.h,d3d11.h,d3d10.h;例如DXGI_STATUS_OCCLUDED,DXGI_STATUS_CLIPPED,DXGI_STATUS_NO_REDIRECTION等。
When I compile I get a lot of macro redefinition warnings caused by winerror.h versus dxgi.h, dxgitype.h, d3d11.h, d3d10.h; for example DXGI_STATUS_OCCLUDED, DXGI_STATUS_CLIPPED, DXGI_STATUS_NO_REDIRECTION etc.
我想这是因为Windows sdk 8已安装。
如何避免这种情况?有什么办法可以从项目中排除这些新库?
I suppose this is because the windows sdk 8 is installed.How can I avoid this? Is there a way I can exclude these new libraries from my project?
推荐答案
我在Visual Studio 2012 Express上遇到了此问题Windows 8;但是,我的错误几乎完全相同,并且此修复程序以Windows SDK为中心。 :
I ran into this problem using Visual Studio 2012 Express on Windows 8; however, my errors were almost exactly the same, and the fix is centered around the Windows SDK. This was in MSDN (see #5):
对于Windows 7(及更低版本)DirectX SDK示例之类的旧项目,必须使用以下步骤来使用D3DX构建应用程序: DirectX SDK:
For legacy projects, such as the Windows 7 (and earlier) DirectX SDK samples, the following steps are necessary to build applications with D3DX using the DirectX SDK:
a。如下修改项目的VC ++目录,以对SDK头文件和库使用正确的顺序。
a. Modify the project’s VC++ directories as follows to use the right order for SDK headers and libraries.
-
打开项目的属性,然后选择 VC ++目录页面
Open Properties for the project and select the VC++ Directories page.
选择所有配置和所有平台。
Select All Configurations and All Platforms.
将这些目录设置如下:
- 包含目录:$(IncludePath); $(DXSDK_DIR)Include
- 库目录:$(LibraryPath); $(DXSDK_DIR)Lib\x86
单击Apply。
选择x64平台。
设置图书馆目录如下:
- 图书馆目录:$(LibraryPath); $(DXSDK_DIR)Lib\x64
b。无论在何处, d3dx9.h, d3dx10.h或 d3dx11.h包含在您的项目中,请确保明确包含 d3d9.h, d3d10.h和 dxgi.h或 d3d11.h。和 dxgi.h首先确保您选择了较新的版本。您可以根据需要禁用警告C4005。但是,此警告表明您正在使用这些标头的旧版本。
b. Wherever "d3dx9.h", "d3dx10.h", or "d3dx11.h" are included in your project, be sure to explicitly include "d3d9.h", "d3d10.h" and "dxgi.h", or "d3d11.h" and "dxgi.h" first to ensure you are picking up the newer version. You can disable warning C4005 if needed; however, this warning indicates you are using the older version of these headers.
c。在项目中删除对DXGIType.h的所有引用。 Windows SDK中不存在该标头,并且DirectX SDK版本与新的winerror.h冲突。
c. Remove all references to DXGIType.h in your project. This header doesn't exist in the Windows SDK, and the DirectX SDK version conflicts with the new winerror.h.
d。所有D3DX DLL通过DirectX SDK安装都安装到您的开发计算机上。确保将必需的D3DX依赖项随任何示例或应用程序(如果将其移至另一台计算机)一起重新分发。
d. All D3DX DLLs are installed onto your development computer by the DirectX SDK installation. Ensure that the necessary D3DX dependencies are redistributed with any sample or with your application if it is moved to another machine.
e。请注意,D3DX11当前使用的替代技术包括和。 D3DXMath替换为 DirectXMath 。
e. Be aware that replacement technologies for current uses of D3DX11 include DirectXTex and DirectXTK. D3DXMath is replaced by DirectXMath.
我不能肯定地说,但是我认为Windows 8 SDK可能是您的问题。可能会有些麻烦,但是使用上述修复程序将有助于使您的代码所需的依赖性更少,并使其与Windows 7和Windows 8兼容。
I can't say for sure, but I think the Windows 8 SDK might be your problem. It may be a bit of a pain, but using the fix above will help make your code require less dependencies as well as making it compatible with both Windows 7 and Windows 8.
这篇关于DirectX标头和winerror.h之间的宏定义冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!