Handling arrays inside structures in VC++

Hi,

I want to expose a structure to C# code from the VC++ .

C# Code:

void AccessStructure()
{
structExample st;
st.x[0] = 4;

//Calling VC++ function
MyC++Func(st);
}

Structure declaration in vc++:

public ref struct structExample
{
public:unsigned char x[2];
public:int y;
};

VC++ function

void MyC++Func(structExample ^ stEx)
{ }

When Compiling the VC++ code i do get the following error

error C4368: cannot define 'x' as a member of managed 'structExample': mixed types are not supported

And also,
Is it possible to pass the structure as value type in the above case

Thanks in Advance

Regards

MadhuSri



Answer this question

Handling arrays inside structures in VC++

  • rlo

    unsigned char is not a managed type!

    Inside a manages struct (self defined value type) you are only allowed to use managed types.



  • Handling arrays inside structures in VC++