Question

We have a c++ library and we are auto generating COM interface for that library. so I auto generated the IDL file and everything was working fine. But over time when more interface were added to COM, We started getting the error

1> Total Format String size = 69336
1> midl : error MIDL2379: the compiler reached a limit for a format string representation. See documentation for advice.

I am getting this error in both VS2008 and VS2010.

Can any one please help me how to fix this problem. I searched all over internet and couldn't find a proper solution. There is one bug reported in Microsoft Connect, but it's status is closed. One work around they suggest is to split the IDL file, which is not possible in my case, cause the interfaces have dependency with one other.

I have uploaded a sample IDL file SampleGenerated.idl

here is the command line to midl.

/W1 /nologo /char signed /env win32 /h "SampleGenerated_h.h" /tlb "Debug\SampleGenerated.tlb"
Was it helpful?

Solution

This is how I managed to do it finally...

First split each interface to separate IDL file

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 )
};
#endif

Interface2.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

Create another IDL file AllInterface.idl containing import of all interface file

import Interface1.idl
import Interface2.idl

Now the main.idl for which we will be creating TLB files

import AllInterface.idl;

The only draw back here is, we have to compile each IDL file separately, if we want to generated the C++/C header file of interfaces.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top