Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2004

Tip: Looking for answers? Try searching our database.

enum handling change in VS 2005

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Craig Klementowski - 23 Jul 2004 18:37 GMT
All,

I've installed the VS 2005 Beta 1 and was trying to build our current
product. I get a compile error when enum value is specified with
classname::enumname::enumvalue. Seems the compiler does not want the
enumname there anymore. This was not a problem with any previous versions of
VS. I could not find any help in any of my programming books or in MSDN. Can
anyone explain the reasons to me? Is this behavior to stay?

class CMyEnumClass

{

public:

enum MyMode

{

MM_Mode1,

MM_Mode2,

MM_Mode3,

MM_Mode4

};

};

int _tmain(int argc, _TCHAR* argv[])

{

// CMyEnumClass::MyMode m = CMyEnumClass::MyMode::MM_Mode3;// in VS 2005 -
error C2825: 'CMyEnumClass::MyMode': must be a class or namespace when
followed by '::'

CMyEnumClass::MyMode m2 = CMyEnumClass::MM_Mode3;//ok in ALL

return 0;

}

Thanks!

Craig Klementowski
Gabest - 23 Jul 2004 20:44 GMT
Actually, I never knew you could include the enum's name in the reference to
the enum, but it seems to be ok for vs2003. However, in my opinion, allowing
this would make the following case legal also, since you can differ which
"something" you want, like s::e1::something or s::e2::something.

struct s
{
enum e1 {something = 1};
enum e2 {something = 2};
};
Ronald Laeremans [MSFT] - 23 Jul 2004 23:09 GMT
The fact that the VC 7.1 compiler allowed this was a bug that we fixed for
the 2005 version. Enums are not scope qualified according to both the C and
C++ standards.

Ronald Laeremans
Visual C++ team

> All,
>
[quoted text clipped - 46 lines]
>
> Craig Klementowski
Craig Klementowski - 26 Jul 2004 15:45 GMT
Thanks Ron. I'll get to cleaning up our code then.

Craig

> The fact that the VC 7.1 compiler allowed this was a bug that we fixed for
> the 2005 version. Enums are not scope qualified according to both the C and
[quoted text clipped - 53 lines]
> >
> > Craig Klementowski
Ken Durden - 28 Jul 2004 15:55 GMT
> The fact that the VC 7.1 compiler allowed this was a bug that we fixed for
> the 2005 version. Enums are not scope qualified according to both the C and
> C++ standards.
>
> Ronald Laeremans
> Visual C++ team

Ron,

Given all the extensive language extensions provided as part of .NET,
I think it would be a very good idea to leave the enum scope
qualification as a language extension.

Not only does it make MC++ more similar to C#.NET, but it's simply a
good idea on its own regard. Lack of enum scoping frequently forces
name mutilation into the enum fields:

enum EColor
{
 eColor_Red,
 eColor_Blue,
}

This sucks in any case where you want to use the textual value of the
enum for printout purposes.

Finally, doesn't removing enum scope qualification in MC++ introduce
possibilities where MC++ will be unable to interact with enums defined
in C#.NET? Since C# supports enum scoping, it seems there could be
cases where duplicate enumerared values (potentially with different
meaning or numeric values) are defined in different enum types. C# can
handle this fine, but MC++ cannot?

Thanks,
-ken
Ronald Laeremans [MSFT] - 29 Jul 2004 00:19 GMT
Hi Ken,

enum class Foo {... } will act identical to an enum defined in C# or another
CLR language.
enum Foo { ... } will act as per the ANSI/ISO C and C++ standards.

If you want a non managed enum to behave the same it is fairly easy to write
a class in standard C++ that has the scoped behavior and use that instead.

Ronald

>> The fact that the VC 7.1 compiler allowed this was a bug that we fixed
>> for
[quoted text clipped - 33 lines]
> Thanks,
> -ken

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.