__property set_ naming issue (managed C++)

  • Thread starter Thread starter Julie
  • Start date Start date
J

Julie

What would you expect from the following:

enum Type { a, b, c };

public __gc class MClass
{
public:
MClass(Type t);
__property void set_Type(Type t);
// etc.
};

When compiling, I get very strange errors (in this case, for the constructor)
where the Type type is compiled as the managed Type property. It is an easy
fix, although the compiler diagnostic is far from intuitive.

Comments?
 
Hi Julie,
What would you expect from the following:

enum Type { a, b, c };

public __gc class MClass
{
public:
MClass(Type t);
__property void set_Type(Type t);
// etc.
};

When compiling, I get very strange errors (in this case, for the constructor)
where the Type type is compiled as the managed Type property. It is an easy
fix, although the compiler diagnostic is far from intuitive.

Comments?

What errors are you getting? Compiling your sample code, I get:
t.cpp
t.cpp(9) : error C2872: 'Type' : ambiguous symbol
could be 't.cpp(4) : Type'
or 't.cpp(1) : System::Type'
t.cpp(10) : error C2872: 'Type' : ambiguous symbol
could be 't.cpp(4) : Type'
or 't.cpp(1) : System::Type'

which actually seems like a very good diagnostic message.
 
Tomas Restrepo (MVP) said:
Hi Julie,


What errors are you getting? Compiling your sample code, I get:
t.cpp
t.cpp(9) : error C2872: 'Type' : ambiguous symbol
could be 't.cpp(4) : Type'
or 't.cpp(1) : System::Type'
t.cpp(10) : error C2872: 'Type' : ambiguous symbol
could be 't.cpp(4) : Type'
or 't.cpp(1) : System::Type'

which actually seems like a very good diagnostic message.


My mistake --

Type should be MyType in all instances.
 
Hi Julie,

My mistake --

Type should be MyType in all instances.

Meaning this, then?

#using <mscorlib.dll>
using namespace System;

enum MyType { a, b, c };

public __gc class MClass
{
public:
MClass(MyType t);
__property void set_Type(MyType t);
// etc.
};

Compiles fine for me :|
 
Back
Top