Link to home
Start Free TrialLog in
Avatar of tamarind
tamarind

asked on

Problem with enum delcaration moving from VC++6.0 -> VC++. .Net

I have to move an old C++ project up to VS.net from 6.0.

i have a declration:

typedef enum
{
     DEBUG =0,
     BLAH,
     BLAH
} MyEnum;

which under .Net gives me
     " syntax error : missing '}' before '='"    
on the DEBUG line

Now i assume that since "DEBUG" is not in its own namespace and im doing a debug build that there are issues with DEBUG already defined. (and the problem goes away under a release build).
My question then is how is it that this simple problem doesnt occur when using 6.0 and then how can i get it to compile under .net?


Thanks.



ASKER CERTIFIED SOLUTION
Avatar of Dexstar
Dexstar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dexstar
Dexstar

@tamarind:

> i have a declration:

Sometimes in my enumerated types, I will use the name of the type as a prefix to the individual values.  That way, I can tell at a glance that the value is part of that enum type.  It also helps to eliminate name collisions (Both of which are nice when you have projects with many enum types).

Applying this system to your type, it would look like this:
     typedef enum
     {
          MyEnum_DEBUG = 0,
          MyEnum_BLAH,
          // Other values go here
     } MyEnum;

Dex*