MC++ function that receives void * parameter
Hello,
I'm writing a wrapper class in MC++ that call a c++ function that its prototype looks like this:
void func1(int length, void *);
How the MC++ wrapper for this will look like?
And how the call from C# will look like?
How can I pass any kind of parameter from C# to my MC++ wrapper class?
Re: MC++ function that receives void * parameter
Assuming C++/CLI (i.e. VS 2005 or later, otherwise upgrade) the wuestion is what managed thing do you wish to pass in "void *" ?
C++/CLI: void Mfunc1 (System::Int32 length, System::Object^ thing)
C#: looks same as C++/CLI (just replace :: with .)
C++: convert reference to thing into a pointer and use that.
e.g.
Code:
GCHandle myGcPointer = GCHandle::Alloc((ManagedReference);
myNativePointer = myGcPointer.Target;
But this is a pointer to a Managed object. This is propably not what you want, so if void * is say a structure, create the native structure and copy from the managed to the native to use in you native call.