"Sarah" <sa...@home.com> wrote in message news:3adf...@shiva.ukisp.net...
> Hi,
>
> I am writing a set of severs and clients that need to share enum
> definitions.
>
> I have made a type library containing the definitions of various enum's
that
> I want to use across various servers and clients.
>
> eg
>
> [uuid(24A1FA59-34DB-11d5-84B5-0050DAE00239)] library MyEnumsLib
> {
> typedef enum MYFIRSTENUM
> {
> MYFIRSTENUM_A = 1,
> MYFIRSTENUM_B,
> MYFIRSTENUM_C
> }MYFIRSTENUM;
> }
>
> This MIDL compiles OK.
>
> For my first server, I have classes that have properties that use these
> enum's. I import the enum's IDL into the IDL. It looks something like
> this:
>
> import "myenums.idl";
> ...
> [
> ]
> interface IMyInterface : IDispatch
> {
>
> [propget, id(1), helpstring("property A")] HRESULT Unused([out, retval]
> MYFIRSTENUM* pA);
> [propput, id(1), helpstring("property A")] HRESULT Unused([in]
MYFIRSTENUM
> A);
> }
> etc.
>
> This MIDL compiles OK, too.
>
> Now, if I OLEVIEW the resulting type library of this server then I note
that
> it contains a re-definition of the used enumerations.
>
> Now if I create a second server similar to this one (ie contains
properties
> of my enum type). However, this server needs to #import the first server
> to know about the interfaces.
>
> Now the problem occurs, because the enum's are defined in the first
server's
> type library AND in the second server. I get redefinition problems when
the
> compiler tries to compile the tlh generated by #import of the first
server.
>
> I use #import with no_namespaces. If I do not use no_namespaces then the
> compiler gets confused between the 2 different enums from the different
> namespaces that are actually the same.
>
> How can I make only 1 definition of the enum to be created during the
> #import process. This must be possible as standard types are used in
> different tlb's but there is no conflict when 2 or more are imported.
>
>
> TIA
>
> Sarah
>
>
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@geocities.com
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Igor Tandetnik" <itand...@whenu.com> wrote in message
news:ePsiOXPyAHA.1080@tkmsftngp05...
import "myenums.idl";
because my interfaces need to know about the enums.
If I use importlib as well (in the library section) then I still get the
enum conflicts.
Any ideas?
Sarah
"Alexander Nickolov" <agnic...@geocities.com> wrote in message
news:eN8vPeQyAHA.572@tkmsftngp05...
If you import the external IDL file with enum definitions (lets say F1.IDL) and
the corresponding TLB (F1.TLB) in your first server's F2.IDL file (which is
correct) the only problem you may have is to provide path the F1.H file in order
to compile the project (importing the F1.IDL in F2.IDL will generate
#include "F1.H" statement in F2.H). So far so good. In this first server you
don't need to use C++ compiler #import directive because you already have the
enum definitions available through F2.H which includes F1.H.
Now, if you use #import directive to import F2.TLB (or F2.EX or F2.DLL -
whatever) in your second server, F3, you will probably have also to #import
F1.TLB in order to provide the enum definitions. I don't see any reason why you
should get redefinition problems in F3 if you don't use F1.IDL in F3.IDL.
Vladimir
import "myenums.idl";
Any ideas?
Sarah
.
#import F3 in F2
and
#import F2 in F3
so when F3 is #import'ed into F2, I get redefinition errors because the
enums are already declared in the server (from its own IDL)
Hence, F2 can get the enums from F1, and F3 gets them from F2. But F2 also
needs to know about F3 and since F2 already gets them from F1 the
redefinition errors occurs.
Is such a design possible? I would imagine there are many situations where
servers depend on each others IDLs, but want to share common type
information.
Sarah
So, you agree that there is no problem to import F1 into F2 and to import F2 into
F3. Now, the only problem is when you import F3 into F2. However, you should not
have any problems to do this last step as well. Importing F3 into F2 doesn't
import the enum definitions because F3 type library doesn't define them. The only
type library which defines the enums is F1.
There is one more important step that you may have missed. You must compile AND
REGISTER F1.TLB first. The registration of F1.TLB will ensure that when you
compile F2.IDL, F2.TLB will only reference the enums, not define them. So, when
you #import "F2.TLB" in F3 that SHOULD NOT include enum definitions. The same is
true for F3.TLB. If F3.IDL is using enum definitions from F1.TLB it should be
compiled only after compiling and registering F1.TLB
I hope that will help.
Vladimir Hristov
Sarah
.
enum MyEnum ...
...
library ...
{
...
enum MyEnum;
}
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@geocities.com
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Sarah" <sa...@home.com> wrote in message news:3adf48e2$1...@shiva.ukisp.net...
Sarah