包含 dshow.h 会导致定义错误

发布于 2024-08-27 10:24:57 字数 1006 浏览 8 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清旖 2024-09-03 10:24:57

通过更改 #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.

神魇的王 2024-09-03 10:24:57

我曾多次遇到此 SDK 集成错误,最近一次是将 win32 控制台应用程序与使用 Windows CoreAudio 的库集成时,并且 stdafx.h 发生错误:

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#ifndef _WIN32_WINNT        // Allow use of features specific to Windows XP or later.                   
#define _WIN32_WINNT 0x0502 // Change this to the appropriate value to target other versions of Windows.
#endif                      

#include <stdio.h>
#include <tchar.h>



// TODO: reference additional headers your program requires here
#include <afx.h>
#include <afxwin.h>

然后为了解决该错误,我在当前包含项下面添加了以下内容:

#include <winioctl.h>
#if (MSC_VER < 1400)
#include <strmif.h>
#endif

希望这对将来遇到此问题的人有所帮助。
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:

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#ifndef _WIN32_WINNT        // Allow use of features specific to Windows XP or later.                   
#define _WIN32_WINNT 0x0502 // Change this to the appropriate value to target other versions of Windows.
#endif                      

#include <stdio.h>
#include <tchar.h>



// TODO: reference additional headers your program requires here
#include <afx.h>
#include <afxwin.h>

Then to resolve the error, I added the following below the current includes:

#include <winioctl.h>
#if (MSC_VER < 1400)
#include <strmif.h>
#endif

Hopefully this will help someone in the future facing this issue.
EB

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文