I have these declarations in C++:
struct objectStruct;
int positionMemory = getPosition();
short size = getSize();
void *allocatedObject; // Originally, it is in C#: IntPtr allocatedObject { get; private set; }
byte[] byteName = Encoding.ASCII.GetBytes("Hello There");
I want to convert these code lines from C# to C++:
string result = Marshal.PtrToStringAnsi(new IntPtr(positionMemory), size);
Marshal.StructureToPtr(objectStruct, new IntPtr(positionMemory), true);
Marshal.Copy(byteName, 0, new IntPtr(positionMemory), size);
long posInMemory = allocatedObject.Offset(size).ToInt64();
I am not familiar with Marshaling.
I don’t know C++ but I do know marshalling so here’s what the lines are doing
I can’t see why you’d actually need to convert most of this to C++, the point of Marshalling is about making managed objects available to unmanaged code and converting unmanaged objects into managed ones, which if you’re operating all in C++ you shouldn’t really need to do, even if it’s managed C++.