Typedef in Managed C++

  • Thread starter Thread starter Shane Bush
  • Start date Start date
S

Shane Bush

I'm trying to expose a typedef from an assembly in a managed C++ code and
cannot seem to make it work. See following code below:

namespace MyTypedef
{
public __gc class MyClass
{
public:
bool b() {return true;}
};

typedef MyClass NewName;
}

When viewed from Idlasm.exe, all I see is MyClass. I cannot use the new
typedef NewName. It seems that NewName is not exposed. Is there a way to
expose it using some Extern keyword, etc. Some suggested that make NewName
to inherit from MyClass. This is not acceptable since this violates the need
to have typedef in the first place. Please help!
 
Shane said:
I'm trying to expose a typedef from an assembly in a managed C++ code and
cannot seem to make it work. See following code below:

namespace MyTypedef
{
public __gc class MyClass
{
public:
bool b() {return true;}
};

typedef MyClass NewName;
}

When viewed from Idlasm.exe, all I see is MyClass. I cannot use the new
typedef NewName. It seems that NewName is not exposed. Is there a way to
expose it using some Extern keyword, etc. Some suggested that make NewName
to inherit from MyClass. This is not acceptable since this violates the need
to have typedef in the first place. Please help!

Typedefs are not exposable in metadata. You can use them inside the
assembly, but not outside.

Ronald Laeremans
Visual C++ team
 
Back
Top