The following code snippet will not compile. I get an error C2337 saying
that the flags attribute is not found, however, if I remove the last
namespace System from the namespace tree, then it compiles fine. What
gives?
#pragma once
using namespace System;
namespace TestA
{
namespace TestB
{
namespace System
{
[Flags]
public __value enum SchedDayType
{
SPECIAL=0,
MON=1,
TUE=2,
WED=4,
THU=8,
FRI=16,
SAT=32,
SUN=64,
WEEKDAY=MON|TUE|WED|THU|FRI,
WEEKEND=SAT|SUN,
EVERYDAY=WEEKDAY|WEEKEND
};
}
}
}

Signature
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
Vladimir Nesterovsky - 11 Nov 2004 15:04 GMT
> The following code snippet will not compile. I get an error C2337 saying
> that the flags attribute is not found, however, if I remove the last
[quoted text clipped - 29 lines]
> }
> }
I believe this is due to compiler's namespaces collision.
Try to write [FlagsAttribute], [System::FlagsAttribute], or even
[::System::FlagsAttribute].

Signature
Vladimir Nesterovsky
e-mail: vladimir@nesterovsky-bros.com
home: www.nesterovsky-bros.com
Ken Varn - 12 Nov 2004 13:44 GMT
Tried all three. None of them seem to work. Technically, the enum should
belong to namespace TestA.TestB.System. Why would there be a collision with
the base CLR System namespace?
Any other suggestions?

Signature
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
>
> > The following code snippet will not compile. I get an error C2337 saying
[quoted text clipped - 34 lines]
> Try to write [FlagsAttribute], [System::FlagsAttribute], or even
> [::System::FlagsAttribute].
Steve McLellan - 12 Nov 2004 14:35 GMT
Possibly the 'using namespace System' is causing the confusion - [Flags]
could reasonably be interpreted as System.Flags.
Steve
> Tried all three. None of them seem to work. Technically, the enum should
> belong to namespace TestA.TestB.System. Why would there be a collision
[quoted text clipped - 41 lines]
>> Try to write [FlagsAttribute], [System::FlagsAttribute], or even
>> [::System::FlagsAttribute].
Ken Varn - 12 Nov 2004 18:05 GMT
That's my guess as well, is there anyway around this or am I forced to
change the namespace naming scheme?

Signature
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
> Possibly the 'using namespace System' is causing the confusion - [Flags]
> could reasonably be interpreted as System.Flags.
[quoted text clipped - 46 lines]
> >> Try to write [FlagsAttribute], [System::FlagsAttribute], or even
> >> [::System::FlagsAttribute].
Tomas Restrepo \(MVP\) - 13 Nov 2004 03:38 GMT
Hi Ken,
> That's my guess as well, is there anyway around this or am I forced to
> change the namespace naming scheme?
To tell you the truth, I wasn't able to get it to work even using namespace
aliases, which is bad (seems like the compiler treats it in a fairly special
way).
But even if you could get it to compile, the naming scheme would just cause
too much trouble later on (way too much stuff that could clash).... you'd be
better off just changing it and avoiding a namespace called System.

Signature
Tomas Restrepo
tomasr@mvps.org