is there a way to have midl generate each interface in a separate .h?
-
16-09-2019 - |
Question
I have a bunch of objects that inherit abstracts interfaces generated from an idl file. Each object that use of theses interfaces include the same file interfaces.h which contain all the c++ generated abstract classes that map to the idl interface.
Each time I change anything into interfaces.idl every classes that depend on this have to be rebuild since interfaces.h change. Is there a flag or something to tell midl to generate each abstract class in its own .h ?
Solution
The only way I can think of is to put each interface in its own IDL file, or divide them into multiple IDLs according to rate-of-change.
Then include (or is it #import -- I forget) these interface IDLs into the main library IDL, which will produce the type library, if you need that.
OTHER TIPS
Here is a sample on how to organize the idl to generate separate .h files and a single typelib. The correct directive is import.
main.idl
import "oaidl.idl";
import "ocidl.idl";
import "frag1.idl";
import "frag2.idl";
[
uuid(1BECE2AF-2792-49b9-B133-BBC89C850D6F),
version(1.0),
helpstring("Bibliothèque de types")
]
library Library
{
importlib("stdole2.tlb");
interface IFrag1;
interface IFrag2;
}
frag1.idl
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(9AEB517B-48B9-4628-8DD3-4A0BA8D39BEF),
dual,
nonextensible,
helpstring("Interface IFrag1"),
pointer_default(unique)
]
interface IFrag1 : IDispatch {
HRESULT frag1();
};
frag2.idl
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(D60835D4-E1B1-40fb-B583-A75373EF15BE),
dual,
nonextensible,
helpstring("Interface IFrag2"),
pointer_default(unique)
]
interface IFrag2 : IDispatch {
HRESULT frag2();
};