8
I would like to pass a float[] to a C method. The C signature looks like:
EXTERN int process_raw(float *inBuffer, float *outBuffer);
in C# the signature is:
public static extern int process_raw(ref float inBuffer, ref float outBuffer);
will it be problematic to pass arrays with a ref to the first member:
process_raw(ref someArray[0], ref anotherArray[0])
thanks!
EDIT: Of course its important to know what the C code does with the floats: It will treat them as arrays and will read values from inBuffer and will write values to outBuffer. As discussed below, the question is whether the whole memory will be pinned during the PInvoke call?
EDIT 2: Another comment. I chose the ref float on purpose because i also wanted to do things like:
fixed(byte* outBuff = buffer)
{
Process(ticks, ref aFloat, ref ((float*)outBuff)[0]);
}
In this case it should be no problem, because the pointer is fixed anyways, but the question for normal array as above remains.