Typedef in Managed C++

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!
 
R

Ronald Laeremans [MSFT]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top