midl error MIDL2379
midl error MIDL2379
我们有一个 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 Connect中报告了一个错误,但它的状态是关闭的。 他们建议的一种解决方法是拆分 IDL 文件,这在我的情况下是不可能的,因为接口彼此依赖。
我已经上传了一个示例 IDL 文件 SampleGenerated .idl
这是 midl 的命令行。
/W1 /nologo /char signed /env win32 /h "SampleGenerated_h.h" /tlb "DebugSampleGenerated.tlb"
这就是我最终设法做到的方式......
首先将每个接口拆分为单独的 IDL 文件
接口1.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 )
};
#endif
接口2.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 文件。
相关文章:
- "error: no matching function for call to"构造函数错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 使用 LuaBridge 将 LuaJIT 绑定到C++会导致"PANIC: unprotected error"
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- C++错误:"error: int aaa::bbb is protected within this context"
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- C++,在int数组中输入字符串或字符会输出0,而不是ascii或error
- 使用 cmake 的 LLVM 构建在 tsan_libdispatch_mac.cc 期间失败; "Error: conflicting types for ..."
- C++ "error: invalid use of void expression"
- struct.error:解压缩 C++ 结构时,解包需要 288 字节的缓冲区
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 从不同目录执行时"symbol lookup error:",否则从构建目录执行时按预期工作
- 对象声明中的模板"error: expected expression"
- 在C++中使用 Catch 测试框架编译错误"error: expected ';' at end of declaration list"
- OpenCV 3.4.1 error readNetFromTensorflow 无法在 cv::d nn::ReadProtoFromBinaryFile 中打开 .pb
- 已解决 - C++ 的崇高文本中的"fatal error: opencv: no such file or directory"
- 为什么我会"error: expected expression"?
- CMake Error at modules/videoio/cmake/detect_ffmpeg.cmake:16
- 如果两个静态库使用相同的另一个静态库,如何避免"LNK2005 Already Defined error"?
- midl error MIDL2379