|
-
October 21st, 2007, 02:44 AM
#1
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?
InfraRed.
Please rate my post, if it helped you.
-
November 1st, 2007, 12:28 PM
#2
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|