I'm trying to pass raw texture data from Texture2D (byte array) to unmanaged C++ code. In C# code array length is about 1,5kk, however in C++ 'sizeof' always returns 8.
C# declaration of native method :
[DllImport("LibName", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ProcessData(byte[] data);
C++:
extern "C" {
__declspec(dllexport) void ProcessData(uint8_t *data) {
//sizeof(data) is always 8
}
}
What am I doing wrong? Is there is a way to pass array without additional memory allocation in C++ code?
sizeof(data)tells you the size of the pointer, you cannot deduce the size of the pointed to array from a pointer, you need to pass it separately