|
|
|
date: Fri, 27 Jan 2006 14:04:27 +0000,
group: microsoft.public.platformsdk.com_ole
back
Re: COM enums
Hi Phil,
> Project #1 has an enum in its IDL file thusly:
> typedef [uuid(blahblah),
> helpstring("My test enum")]
> enum
> {
> CASE1 = 0,
> CASE2 = 1,
> CASE3 = 2
> } MyTestEnum;
> Project #2 #imports the type library from project 1 with no_namespace
> named_guids. I can use all the interfaces and classes from my code no
> probs but the compiler says unrecognised symbol CASE1 or
> MyTestEnum.CASE1. What's the correct way of doing this?
First, I'd skip the typedef;
[uuid(blahblah),helpstring("My test enum")]
enum MyTestEnum
{
// ...
};
Then make sure the enum is mentioned inside the library block of project
#1's IDL, and it should carry over into the typelib, and be accessible from
#2.
--
Best Regards,
Kim Grsman
date: Sat, 28 Jan 2006 10:11:05 +0000 (UTC)
author: Kim Gräsman
Re: COM enums
"Phil Da Lick!"
wrote in message
news:43db919f$0$82676$ed2619ec@ptn-nntp-reader03.plus.net
> Kim Grsman wrote:
>> First, I'd skip the typedef;
>>
>> [uuid(blahblah),helpstring("My test enum")]
>> enum MyTestEnum
>> {
>> // ...
>> };
>>
>> Then make sure the enum is mentioned inside the library block of
>> project #1's IDL, and it should carry over into the typelib, and be
>> accessible from #2.
>
> MIDL wont compile it without the typedef first.
Yes it would. When you use the enum as a parameter, you have to
explicitly say "enum MyTestEnum".
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Sat, 28 Jan 2006 12:34:16 -0500
author: Igor Tandetnik
Re: COM enums
Igor Tandetnik wrote:
> "Phil Da Lick!"
> wrote in message
> news:43db919f$0$82676$ed2619ec@ptn-nntp-reader03.plus.net
>
>>Kim Grsman wrote:
>>
>>>First, I'd skip the typedef;
>>>
>>>[uuid(blahblah),helpstring("My test enum")]
>>>enum MyTestEnum
>>>{
>>> // ...
>>>};
>>>
>>>Then make sure the enum is mentioned inside the library block of
>>>project #1's IDL, and it should carry over into the typelib, and be
>>>accessible from #2.
>>
>>MIDL wont compile it without the typedef first.
>
>
> Yes it would. When you use the enum as a parameter, you have to
> explicitly say "enum MyTestEnum".
No, I mean MIDL won't compile the actual enum declaration:
[
uuid(blahblah),
helpstring("a test enumeration")
]
enum
{
case1 = 0,
case2 = 1,
case3 = 2
} MyTestEnum; // MIDL2001
error MIDL2001 : instantiation of data is illegal; you must use "extern" or "static" : [ ]
Whereas:
typedef
[
uuid(blahblah),
helpstring("a test enumeration")
]
enum
{
case1 = 0,
case2 = 1,
case3 = 2
} MyTestEnum;
works fine
date: Sat, 28 Jan 2006 22:17:03 +0000
author: Phil Da Lick!
|
|