I have the need to call a C function via PInvoke from C#, passing a pointer to a struct, and this struct contains a pointer as well.
The struct can be simplified in C to,
struct myStruct {
int myInt;
float *myFloatPointer;
}
The function declaration can be simplified to
void myFunc(myStruct *a);
In C#, I declare the function as such
[DllImport("my_library.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void myFunc(ref myStruct a);
Unfortunately, I cannot determine how to declare the struct in C# with the pointer parameter present.
The C function does not allocate the memory pointed to by the float pointer, it only modifies it. I would prefer to solve this without the use of the unsafe keyword.
I have called functions via PInvoke with float* parameters successfully using float[], but that does not seem to work here.
Thanks in advance.