包含 dshow.h 会导致定义错误
我正在尝试使用 DirectShow 进行音频播放做一些事情。我有一个头文件,顶部是:
#pragma once
#include <dshow.h>
#pragma comment(lib, "strmiids.lib")
然后它继续定义一个类。 当包含 dshow.h 时,我收到以下编译错误:
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\ddraw.h(703):错误 C2011:'_DDPIXELFORMAT':'struct' 类型重新定义
c:\program files\microsoft sdks\windows\v7.0\include\ksmedia.h(5749):请参阅“_DDPIXELFORMAT”声明
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\ddraw.h(2249):错误 C2079:“_DDSURFACEDESC::ddpfPixelFormat”使用未定义的结构“_DDPIXELFORMAT”
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\ddraw.h(2292):错误 C2079:“_DDSURFACEDESC2::ddpfPixelFormat”使用未定义的结构“_DDPIXELFORMAT”
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\strmif.h(12918):错误 C2011:'tagTIMECODE_SAMPLE':'struct' 类型重新定义
c:\program files\microsoft sdks\windows\v7.0\include\ksmedia.h(5274):请参阅“tagTIMECODE_SAMPLE”的声明
我无法弄清楚在这种情况下会导致这些错误的原因。如果有什么区别的话,头文件是 MFC 项目的一部分。有什么建议吗?
I am trying to do a few things using DirectShow for audio playback. I have a header file, at the top is:
#pragma once
#include <dshow.h>
#pragma comment(lib, "strmiids.lib")
and then it goes on to define a class.
When including dshow.h I get the following complilation errors:
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\ddraw.h(703) : error C2011: '_DDPIXELFORMAT' : 'struct' type redefinition
c:\program files\microsoft sdks\windows\v7.0\include\ksmedia.h(5749) : see declaration of '_DDPIXELFORMAT'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\ddraw.h(2249) : error C2079: '_DDSURFACEDESC::ddpfPixelFormat' uses undefined struct '_DDPIXELFORMAT'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\ddraw.h(2292) : error C2079: '_DDSURFACEDESC2::ddpfPixelFormat' uses undefined struct '_DDPIXELFORMAT'
C:\Program Files\Microsoft SDKs\Windows\v7.0\include\strmif.h(12918) : error C2011: 'tagTIMECODE_SAMPLE' : 'struct' type redefinition
c:\program files\microsoft sdks\windows\v7.0\include\ksmedia.h(5274) : see declaration of 'tagTIMECODE_SAMPLE'
I can't figure out what would cause these errors in this case. The header file is part of an MFC project if that makes any difference. Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过更改 #include 定义的顺序解决了这个问题。我将上面代码定义的头文件移到了顶部,现在可以正常工作了。一定是与另一个文件中的某些代码发生冲突,可能是一些与 directSound 相关的东西。
Fixed this by changing the order of the #include definitions. I moved the header file that the above code was defined in to the top and it works ok now. Must have been a clash with some code in another file, possibly some directSound related stuff.
我曾多次遇到此 SDK 集成错误,最近一次是将 win32 控制台应用程序与使用 Windows CoreAudio 的库集成时,并且 stdafx.h 发生错误:
然后为了解决该错误,我在当前包含项下面添加了以下内容:
希望这对将来遇到此问题的人有所帮助。
EB
I have faced this SDK integration error a couple times, most recently when integrating a win32 console app with a library that uses Windows CoreAudio and the error occurred with a stdafx.h:
Then to resolve the error, I added the following below the current includes:
Hopefully this will help someone in the future facing this issue.
EB