Hello All,
I have effectively the following (part of a much bigger header):
namespace X
{
namespace Y
{
__gc public class EnvironmentList
{
// rest of declaration
};
__gc public class AnotherClass
{
public:
__property EnvironmentList* get_EnvironmentList( ); // **!**
private:
EnvironmentList* p_EnvironmentList; // **!**
};
} // namespace Y
} // namespace X
When I compile this the two lines marked **!** produce error C2327
saying that "X::Y::AnotherClass::EnvironmentList" is not a type name,
static, or enumerator.
I can get around this by fully qualifying the type (eg.
X::Y::EnvironmentList) in each case, but would prefer not to do so
because I have other cases which work perfectly (different class names
however).
I thought this might be due to an ambiguity with an existing class
named EnvironmentList in another namespace, but cannot find any
reference to such in MSDN. In addition, I tried a simple test
application to show how CL reports ambiguities and it seems to report
them correctly.
Any help appreciated...
Tomas Restrepo \(MVP\) - 30 Mar 2005 04:05 GMT
Kevin,
> Hello All,
>
[quoted text clipped - 40 lines]
>
> Any help appreciated...
You're problem is that the property is called the same as the type, so by
the time the compiler parses the property declaration, it has introduced a
new name "EnvironmentList - the property", so when it parses the field
member declaration, it doesn't know whether you're referencing the property
or the type.
The fix is actually quite simple: Just move the field declaration before the
property declaration (or rename the property, but that's not needed here):
__gc public class AnotherClass
{
private:
EnvironmentList* p_EnvironmentList; // **!**
public:
__property EnvironmentList* get_EnvironmentList( ); // **!**
};

Signature
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/
kevin_g_frey@hotmail.com - 30 Mar 2005 04:45 GMT
Thanks, Tom. I have in fact chosen to rename the property (it actually
makes it more consistent with some others we have). But at least I now
know what the problem is!