C++/CLI and fixed size buffers

L

ldawson

From the same C++ source code, I'm attempting to generate both an unmanaged
DLL and a managed assembly. This will eliminate interop as the calling code
is slowly migrated to .NET.
However, C++ native compilation allows fixed size buffers (e.g. char
pathName[128]) which we've used to represent a memory mapped file, and I
can't find out how to implement the same in C++/CLI
i.e.

#ifdef _MANAGED
ref class MyClass
#else
class MyClass
#endif
{
char pathName[128];
}

For managed compilation, a compiler error is given saying that mixed types
are not supported.

In C# unsafe code blocks, the fixed keyword is available for fixed size
buffers
public fixed char pathName[128];

What is the equivalent in C++/CLI?
 
N

Nishant Sivakumar

Something like this :-

ref class R
{
array<char>^ arr;
R()
{
arr = gcnew array<char>(128);
}
};
 

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