thank all of you to have patience to answer my question.
actually,I want to use c lib to store c# object address,
like this:
In c lib, I wrote a structure, and two method operate on
it.
typedef struct
{
void *csharp_obj;
}c_struct;
void set_c_charp_obj(c_struct *cstr, void *csharpObj)
{
cstr->csharp_obj = csharpObj;
}
void *get_c_charp_obj(c_struct *cstr)
{
return cstr->csharp_obj;
}
In C#, I define c lib function prototype:
public extern void SetCCharpObj(IntPtr cStruct, IntPtr
obj);
public extern IntPtr GetCCharpObj(IntPtr cStruct);
then ,you will understand that I want to get C# object
addr and send it as IntPtr to c lib.so that, I store the
pointer of the c# object in c lib for future use.But when
i debug the program, I always get a error.How can I
handle this scenario?and when I fetch the pointer of c#
object, how can i cast it and use it as a object in c#?
thanks