0

I'm creating a COM type library with over one hundred interfaces. Defining all of the interfaces and coclasses in a single library is unreasonable... the IDL file becomes thousands of lines long! So I'm trying the idea of putting each interface in its own file, and using imports to satisfy its dependencies.

What strategies can I use to manage this many interfaces? I'm trying to use import directives everywhere, but I'm stuck trying to get them included in the TLB. I've tried #include in the library, but things seem to get funky with dependencies.

ExampleA.idl

import "oaidl.idl", "ocidl.idl";
[ uuid(...) ] interface IExampleA : IDispatch { ... }

ExampleB.idl

import "oaidl.idl", "ocidl.idl", "IExampleA.idl";
[ uuid(...) ] interface IExampleB : IExampleA { ... }

ExampleLibrary.idl

// Should I put some imports here? They won't be included in the library.
import "IExampleA.idl";
import "IExampleB.idl";

[ uuid(...) ]
library InfrastructureLib
{
    // This? Imports in a library don't actually include the types
    import "IExampleA.idl";
    import "IExampleB.idl";

    // Or this? I get class redefinition errors trying #include 
    #include "IExampleA.idl"
    #include "IExampleB.idl"

    // Is there another way?
};
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
  • Just out of curiosity, what kind of library are you writing that requires 100+ interfaces? I think my brain would explode if I tried to use it. If it were me I would try to group them in some logical order and separate them out into different libraries. – Luke Jul 16 '10 at 17:52
  • ^_^ We have a lot of infrastructure (logging, file I/O, etc.) and then communication classes (a bunch of classes representing different messages). I suppose I could put them into separate libraries... would importlib let me group them all into one master library then? Hmm.... – sourcenouveau Jul 16 '10 at 18:11
  • Descriptions such as "I get compilation errors trying #include" are not very helpful, you know, unless you really don't care of the outcome. – sharptooth Jul 19 '10 at 05:15
  • They're class redefinition errors--I updated the comment. – sourcenouveau Jul 19 '10 at 13:03

1 Answers1

0

I think your plan to split up the interfaces into multiple tlb files is fine, however I dont understand why you appear to be generating the files by hand?

My suggestion would be to split the interfaces into multiple typelibraries but use a typelibrary editor to create them.

A type library editor comes with every version of Delphi, but if you dont have this there should be a few available on the net.

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
  • I had no idea such a thing existed... is one included with Visual Studio? I am creating COM objects and interfaces using ATL. – sourcenouveau Jul 17 '10 at 18:11