Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Fri, 27 Jan 2006 14:04:27 +0000,    group: microsoft.public.platformsdk.com_ole        back       


COM enums   
Hi,

Situation:
VS.NET2k3 c++ projects winxp

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?
date: Fri, 27 Jan 2006 14:04:27 +0000   author:   Phil Da Lick!

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   
Kim Grsman wrote:
> 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.

MIDL wont compile it without the typedef first.

I've added enum MyTestEnum; to the end of the library block and all is 
well with MIDL but I still can't use it in other projects that import 
the typelib.
date: Sat, 28 Jan 2006 15:45:44 +0000   author:   Phil Da Lick!

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!

Re: COM enums   
Hi Phil,

> 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

You didn't do what I said :-)

That's not a declaration, that's an instantiation. The enum name should go 
after the enum keyword;

  [...]
  enum MyTestEnum
  {
  };

--
Best Regards,
Kim Grsman
date: Sun, 29 Jan 2006 13:54:18 +0000 (UTC)   author:   Kim Gräsman

Re: COM enums   
Kim Grsman wrote:
> Hi Phil,
> 
>> 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
> 
> 
> You didn't do what I said :-)
> 
> That's not a declaration, that's an instantiation. The enum name should 
> go after the enum keyword;
> 
>  [...]
>  enum MyTestEnum
>  {
>  };

Much obliged :)
date: Sun, 29 Jan 2006 15:20:55 +0000   author:   Phil Da Lick!

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us