MC++ FAQ
Thursday 06 | 27 | 2002
Attributes in Enum Values
Why do I always get an error when trying to add an attribute to an enum value?

R/ You're probably doing something like this:


public __gc class MyCustomAttribute : public Attribute
{
   public:
      MyCustomAttribute(String* desc) {
      }
   // rest of implementation
};

__value enum MyEnum {
   [ MyCustomAttribute(S"Value 1") ] 
   value_1 = 1,
   [ MyCustomAttribute(S"Value 2") ] 
   value_2 = 2,
};

And you're getting a C2143 and a few other errors, right? The cause is a bug in the current MC++ compiler that doesn't allow it to parse attributes in an enum declaration, so there's no workaround for it.

Posted by tomasr at June 27, 2002 01:10 AM
Comments
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?

Copyright(C) 2002, Tomas Restrepo, All rights reserved. Powered by Movable Type 2.63