tags:

views:

57

answers:

1

I have the following problem:

I have to projects Project1 and Project2. In Project1 I have an interface IMyInterface. In Project2 I have an interface IMyInterface2 with a method that receives a pointer to IMyInterface1.

When I use import "Project1.idl"; in my Project2.idl, a #include "Project1.h" appears in Project2___i.h. But this file does not even exist!. What is the proper way to import an interface defined into other library into a idl file?

I tried to replace the #include "Project1.h" by *#include "Project1_i.h"* or *#include "Project1_i.c"*, but it gave me a lot of errors.

I also tried to use importlib("Project1.tlb") and define my interface IMyInterface2 within the library definition. But when I compile Project2PS project, an error is raised (something like dlldata.c is not generated if no interface is defined).

I tried to create a dummy Project1.h. But when Project2___i.h is compiled, compiler cannot find MyInterface1. And if I include Project1___i.h I get a lot of errors again!

Apparently, it is a simple issue, but I don't know how to solve it. I'm stuck with that!.

By the way, I'm using VS2008 SP1.

Thanks in advance.

+2  A: 

Don't include the *_i.c file from a header. You can do so from a source file (.cpp) as a simple way to get it linked in.

EDIT

You can treat separate IDL files and their products completely independently. There is no need to worry about combining them any earlier than at the stage where you include the ordinary header file generated from each IDL file.

To deal with IDL, you add it to a project. This causes MIDL to run on it, and output a header file. (It will by default also output other things, but they aren't essential).

I recommend that you make your IDL files write their headers out to a single, common include directory, which you can then add to the include path for any projects that need to work with the interfaces.

Then just use #include to pull in the header file for each interface you need. As the common include directory is on the project's path, the nested #include in header2.h will be able to pull in header1.h.

Daniel Earwicker
I really thanks your answer Earwicker!I will clarify a little bit my problem. I have to projects Project1 and Project2. In Project1 I have an interface IMyInterface. In Project2 I have an interface IMyInterface2 with a method that receives a pointer to IMyInterface1. When I use import "Project1.idl"; in my Project2.idl, a #include "Project1.h" appears in Project2_i.h. But this file does not exist.What is the proper way to import an interface defined into other library into a idl file?
Cesar
See edit above.
Daniel Earwicker