HELP Using Enums through importlib??? 
Author Message
 HELP Using Enums through importlib???

Hello,
I am sorry if there is a better forum to ask this question in!  I was unable
to find a generic COM forum.

Here is my question:

I have (2) type libraries:   a.tlb & b.tlb

I am trying to use enums from one type library in another type library
through importlib()
I am able to use the imported enum type.  But I am not able to use the
imported enum values as constants!
How can I use these imported enum values through importlib()?   I would
prefer not to use import  "a.idl"!

See the following code for a clearer picture of the problem:

FILE a.idl:
[...]
library a
{
    typedef [public, v1_enum] enum tagMY_IMPORT_ENUM_E
    {
    MY_IMPORT_ENUM_VALUE_A    = 0x01,
    MY_IMPORT_ENUM_VALUE_B    = 0x02
    } MY_IMPORT_ENUM_E;

Quote:
};    // end of library a

File b.idl:
[...]
library b
{
    importlib(a.tlb);

    typedef [v1_enum] enum tagMY_LOCAL_ENUM_E
    {
    MY_LOCAL_ENUM_VALUE_A    = 0x01,
    MY_LOCAL_ENUM_VALUE_B    = 0x02
    } MY_LOCAL_ENUM_E;

    [...]
    interface ISomeInterface : IDispatch
    {
        // This next line Fails: error MIDL2035 : constant expression
expected
        [id(1)] HRESULT SomeFunctionA([in, optional,
defaultvalue(MY_IMPORT_ENUM_VALUE_A)] MY_IMPORT_ENUM_E  value);
        // This next line Succeedes as expected
        [id(2)] HRESULT SomeFunctionB([in, optional,
defaultvalue(MY_LOCAL_ENUM_VALUE_A)] MY_LOCAL_ENUM_E  value);
    };

Quote:
};    // end of library b

Thanks,
Keith Parsons



Tue, 27 Jul 2004 12:59:11 GMT  
 HELP Using Enums through importlib???
Could be a bug in MIDL. Try using import in the begginning of the file
(in addition to importlib() in the library section).

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> Hello,
> I am sorry if there is a better forum to ask this question in!  I was unable
> to find a generic COM forum.

> Here is my question:

> I have (2) type libraries:   a.tlb & b.tlb

> I am trying to use enums from one type library in another type library
> through importlib()
> I am able to use the imported enum type.  But I am not able to use the
> imported enum values as constants!
> How can I use these imported enum values through importlib()?   I would
> prefer not to use import  "a.idl"!

> See the following code for a clearer picture of the problem:

> FILE a.idl:
> [...]
> library a
> {
>     typedef [public, v1_enum] enum tagMY_IMPORT_ENUM_E
>     {
>     MY_IMPORT_ENUM_VALUE_A    = 0x01,
>     MY_IMPORT_ENUM_VALUE_B    = 0x02
>     } MY_IMPORT_ENUM_E;
> };    // end of library a

> File b.idl:
> [...]
> library b
> {
>     importlib(a.tlb);

>     typedef [v1_enum] enum tagMY_LOCAL_ENUM_E
>     {
>     MY_LOCAL_ENUM_VALUE_A    = 0x01,
>     MY_LOCAL_ENUM_VALUE_B    = 0x02
>     } MY_LOCAL_ENUM_E;

>     [...]
>     interface ISomeInterface : IDispatch
>     {
>         // This next line Fails: error MIDL2035 : constant expression
> expected
>         [id(1)] HRESULT SomeFunctionA([in, optional,
> defaultvalue(MY_IMPORT_ENUM_VALUE_A)] MY_IMPORT_ENUM_E  value);
>         // This next line Succeedes as expected
>         [id(2)] HRESULT SomeFunctionB([in, optional,
> defaultvalue(MY_LOCAL_ENUM_VALUE_A)] MY_LOCAL_ENUM_E  value);
>     };
> };    // end of library b

> Thanks,
> Keith Parsons




Wed, 28 Jul 2004 02:57:58 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. i can't use types from another tlb using importlib

2. MIDL namespace problems using importlib

3. Using importlib in an IDL file?

4. enums indexed by enums (again)

5. Enums and Intellisense in VS.NET using Managed C++ extensions

6. unexpected outcome when using Enums in arithmetic

7. Using enums to define array sizes

8. Problems using enums as array indexes

9. Using 'enums' from 3rd party controls

10. Help with alignment and size of packed structs with enums

11. Help embedding enums or defines within string const.

12. Help on enums

 

 
Powered by phpBB® Forum Software