Re: Managed enums

"Eames, Andrew" <[email protected]> Mon, 22 Oct 2007 14:22:43 -0400
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
You can use a managed enum in native code but it's a tad messy if you
have to compile it both natively and with /clr since the scoping rules
for managed and native enums are different - i.e. with a managed enum
you have to say Color::Red and if its native you have to say Red

This has become somewhat of a moot point for me anyway since I have
found that I cannot get C++ code compiled with /clr to execute correctly
in the MS Unit Test framework since the CRT requires you are in the
default domain
  Andrew=20

-----Original Message-----
From: Discussion relating to the specifics of the C# and Managed C++
languages [mailto:[email protected]] On Behalf Of Peter
Ritchie
Sent: Monday, October 22, 2007 2:01 PM
To: [email protected]
Subject: [Spam:***** SpamScore] Re: [DOTNET-CX] Managed enums

On Mon, 22 Oct 2007 11:17:37 -0400, Andrew Eames <[email protected]>
wrote:
>When I do this, the enum is marked as internal so this is not actually
>very helpful - is there a way to make it public (other than making it a
>managed enum) - I dont see the NativeEnumAttribute either

The problem is that default access is internal.  To override that you
need
to specific either the access on the enum or its parent class.
Unmanaged
C++ doesn't have that concept and you'd have to used C++/CLI syntax
which
only applies to managed types.

I know of nothing that changes the default access to be something other
than internal for a project or a module.

I also see nothing in the .NET 1.0, 1.1, or 2.0 assemblies about
NativeEnumAttribute.  My guess is the documentation is wrong and
NativeEnumAttribute is replaced by ScopelessEnumAttribute.

You should be able to use a managed enum in native code in the same
module, if that's what you need to do.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


--=20
BEGIN-ANTISPAM-VOTING-LINKS
------------------------------------------------------

Teach CanIt if this mail (ID 9928039) is spam:
Spam:
http://mail-gw.cognex.com/canit/b.php?c=3Ds&i=3D9928039&m=3D2c97fc43a74c
Not spam:
http://mail-gw.cognex.com/canit/b.php?c=3Dn&i=3D9928039&m=3D2c97fc43a74c
Forget vote:
http://mail-gw.cognex.com/canit/b.php?c=3Df&i=3D9928039&m=3D2c97fc43a74c
------------------------------------------------------
END-ANTISPAM-VOTING-LINKS

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This list is hosted by DevelopMentor=AE  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com