gpt4 book ai didi

c++ - VS2010 IntelliSense 说 : CComPtr is not a template

转载 作者:行者123 更新时间:2023-11-30 00:52:23 25 4
gpt4 key购买 nike

我在尝试将基于 directshow 的直播播放器编写为 ActiveX 控件时遇到了问题。

我先用VS2010创建了一个MFC ActiveX控件工程(VC++类下),并在控件上附加了一个对话框,然后用一个简单的 html 页面对其进行了测试。

到目前为止它运行良好,但是当我尝试使用 CComPtr 添加一些 directshow 代码时,编译器显示以下错误(我还附上了行号和文件):

29  IntelliSense: CComPtr is not a template   (CIceBaseLivestreamPlayerCore.h, Line 37)
30 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 38)
31 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 44)
32 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 44)
33 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 47)
34 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 48)
35 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 49)
36 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 19)
37 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 20)
38 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 21)
39 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 22)
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 14 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 19)
Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 20)
Error 20 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 21)
Error 23 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 22)
Error 25 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_vInfTee' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 27 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_fileWriter' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 28 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_AVIMux' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 26 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_aInfTee' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 12 error C2614: 'CIceBaseLivestreamPlayerCore' : illegal member initialization: 'm_pGraph' is not a base or member (CIceBaseLivestreamPlayerCore.h, Line 18)
Error 11 error C2614: 'CIceBaseLivestreamPlayerCore' : illegal member initialization: 'm_pControl' is not a base or member (CIceBaseLivestreamPlayerCore.h, Line 18)
Error 3 error C2238: unexpected token(s) preceding ';' (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 6 error C2238: unexpected token(s) preceding ';' (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 15 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 19)
Error 18 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 20)
Error 21 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 21)
Error 24 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 22)
Error 1 error C2143: syntax error : missing ';' before '<' (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 4 error C2143: syntax error : missing ';' before '<' (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 13 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 19)
Error 16 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 20)
Error 19 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 21)
Error 22 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 22)
Error 7 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 44)
Error 8 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 47)
Error 9 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 48)
Error 10 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 49)

所有这些错误似乎都表明 CComPtr 有一些奇怪的地方,但我不知道出了什么问题。

我在 stdafx.h 的底部添加了两个头文件,如下所示:

#include <streams.h>
#include <atlbase.h>

下面我把我的CIceBaseLivestreamPlayerCore.h和CIcePlayAndSaveAXCore.h的一部分列出来,上面错误中涉及的所有行都包括在内。

CIceBaseLivestreamPlayerCore.h:

#pragma once
#include "stdafx.h"

class CIceBaseLivestreamPlayerCore
{
...
15 CIceBaseLivestreamPlayerCore():
16 ..., m_pGraph(NULL), m_pControl(NULL),
17 ...
18 { ; }
...
37 CComPtr<IGraphBuilder> m_pGraph;
38 CComPtr<IMediaControl> m_pControl;
...
44 HRESULT ConnectFilters(CComPtr<IBaseFilter> pIn, CComPtr<IBaseFilter> pOut, const AM_MEDIA_TYPE& mType);
...
47 HRESULT MatchPin(CComPtr<IPin>, PIN_DIRECTION, BOOL, BOOL*);
48 HRESULT IsPinConnected(CComPtr<IPin>, BOOL*);
49 HRESULT IsPinDirection(CComPtr<IPin>, PIN_DIRECTION, BOOL*);
};

CIcePlayAndSaveAXCore.h:

#pragma once
#include "CIceBaseLivestreamPlayerCore.h"

class CIcePlayAndSaveAXCore : public CIceBaseLivestreamPlayerCore
{
...
7 CIcePlayAndSaveAXCore() :
8 m_AVIMux(NULL), m_fileWriter(NULL), m_aInfTee(NULL), m_vInfTee(NULL)
9 { ; }
...
19 CComPtr<IBaseFilter> m_AVIMux;
20 CComPtr<IBaseFilter> m_fileWriter;
21 CComPtr<IBaseFilter> m_aInfTee;
22 CComPtr<IBaseFilter> m_vInfTee;
};

我的项目的附加依赖项是“strmbasd.lib;winmm.lib;uuid.lib;”。

就这些了..希望有人能给我答案如何解决它,或者只是给我任何意见或建议作为我应该做什么的方向。

感谢任何帮助。

这是我第一次发布英语问题(虽然我不是母语人士..),因此,如果我在提问时有任何遗失或做错了什么,请告诉我。

非常感谢。 :)

最佳答案

经过多次尝试,终于找到问题并解决了。

我想我应该把结果放在这里,因为可能会有人遇到同样的问题,并且不知道如何像我一样解决它。我不知道回答我自己的问题是否违反了 stackoverflow 的礼节,所以我将不接受这个答案。

正如我所说,我已经输入了 #define <atlbase.h>进入我的底部 stdafx.h .但是因为我正在制作一个 MFC ActiveX 控件项目,IDE (VS 2010) 会自动在我的 stdafx.h 中生成一个#define 语句。 ,即 #define _ATL_NO_AUTOMATIC_NAMESPACE .

当我们使用 #include <atlbase.h>在平时,编译器会执行using namespace ATL默认情况下,但是这个 #define _ATL_NO_AUTOMATIC_NAMESPACE语句取消此行为,然后导致我的编译器所说的命名冲突。

因此,在这种情况下,只需使用 ATL::CComPtr用于声明或直接使用 using ATL::CComPtr出现CComPtr的语句,该编译错误将被消除。

关于c++ - VS2010 IntelliSense 说 : CComPtr is not a template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19241559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com