IDL中用于导入的类型库的非限定名称

时间:2010-06-24 15:30:49

标签: c++ com namespaces idl

我创建了一个实现一些接口的COM类。我想为这个接口添加一个方法。此方法的参数是指向某些外部olb文件中定义的接口的指针。在我的项目中,这个olb文件导入时没有no_namespace指令。因此,方法参数中的接口名称必须在h \ cpp文件中限定。但是MIDL不识别名称空间并在方法中生成具有不合格接口的头文件。所以,错误C2061。一点点样本:

//stdafx.h
#import "somelib.olb" named_guids no_function_mapping

在somelib.olb中定义的接口Foo。我项目中的合格名称是someLib::Foo

//myproject.idl
...
[
  object,
  uuid(...),
  ...
]
library MyProjectLib
{
  importlib(somelib.olb);
  ...
  [
     object,
     uuid(...),
     helpstring(...),
     pointer_default(unique)
  ]
  interface IMyInterface : IUnknown{
     [propputref, helpstring("...")] HRESULT Bar ([in] IFoo* Parent);
  };

MIDL生成头文件MyProject.h

//MyProject.h
...
IMyInterface : public IUnknown
{
public:
    virtual /* [helpstring][propputref] */ HRESULT STDMETHODCALLTYPE putref_Bar( 
        /* [in] */ /* external definition not present */ IFoo *Parent) = 0;
};
...

错误消息

error C2061: syntax error : identifier 'IFoo'

如何解决这个问题?提前谢谢。

0 个答案:

没有答案
相关问题