I'm calling C++ method from C# code and passing the pointer of first element of a 2D array, and the dimensions of the array to the C++ function:
C# code
fixed (bool* addressOfMonochromeBoolMatrixOfBitmap = &monochromeBoolMatrixOfBitmap[0, 0]
{
NativeGetUniquenessMatrixOfBitmap(addressOfMonochromeBoolMatrixOfBitmap, Width, Height);
}
C++ code
extern "C" __declspec(dllexport) void NativeGetUniquenessMatrixOfBitmap ( bool* addressOfMonochromeBoolMatrixOfBitmap,
int boolMatrixWidth, int boolMatrixHeight)
{
}
In the C++ code I want to cast the bool* pointer to 2D array, in order to access the elements using conventional array syntax: someArray[1][4]. I've tried this code:
bool (*boolMatrix)[boolMatrixWidth][boolMatrixHeight] = (bool (*)[boolMatrixWidth][boolMatrixHeight])addressOfMonochromeBoolMatrixOfBitmap;
But it doesn't compile giving the message "expected constant expression".
Please share any ideas. Thanks.