我们有一个c++库,我们正在为该库自动生成COM接口。所以我自动生成IDL文件,一切都很好。但是随着时间的推移,当更多的接口被添加到COM中时,我们开始得到错误
1> Total Format String size = 69336
1> midl : error MIDL2379: the compiler reached a limit for a format string representation. See documentation for advice.我在VS2008和VS2010中都得到了这个错误。
有谁能帮我解决这个问题吗?我在网上到处搜索,找不到合适的解决方案。在Microsoft中报告了一个bug,但它的状态已经关闭。他们建议的一项工作是拆分IDL文件,在我的情况下这是不可能的,因为接口相互依赖。
我已经上传了一个样例IDL文件SampleGenerated.idl
这是midl的命令行。
/W1 /nologo /char signed /env win32 /h "SampleGenerated_h.h" /tlb "Debug\SampleGenerated.tlb"发布于 2013-10-30 08:23:28
我终于做到了这一点..。
首先,将每个接口拆分为单独的IDL文件。
Interface1.idl
Interface Interface2; // forward declaration
#ifndef __Interface1_IDL_FILE_
#define __Interface1_IDL_FILE_
import "AllIDLInterface.idl";
[
object,
uuid(66006A2F-B777-4e2f-A0CA-D5BE00000015),
dual,
nonextensible,
pointer_default(unique)
]
interface Interface1 : IUnknown{
HRESULT getInterface2([out, retval]Interface2** outVal )
};
#endifInterface2.idl
Interface Interface1;// forward delcarations
#ifndef __Interface2_IDL_FILE_
#define __Interface2_IDL_FILE_
import "AllIDLInterface.idl";
[
object,
uuid(66006A2F-B777-4e2f-A0CA-D5BE00000015),
dual,
nonextensible,
pointer_default(unique)
]
interface Interface2 : IUnknown
{
HRESULT getInterface1([out, retval]Interface1** outVal )
};
#endif创建另一个包含导入所有接口文件的IDL文件AllInterface.idl
import Interface1.idl
import Interface2.idl现在我们将为其创建TLB文件的main.idl。
import AllInterface.idl;这里唯一的好处是,如果我们想要生成接口的C++/C头文件,我们必须分别编译每个IDL文件。
https://stackoverflow.com/questions/19626569
复制相似问题