C# C字节[]到C++;未签名字符*-在Android上崩溃,在Windows上正常
这里的第一个问题,在过去的一周里我一直试图解决这个问题,但是我被卡住了C# C字节[]到C++;未签名字符*-在Android上崩溃,在Windows上正常,c#,android,c++,C#,Android,C++,这里的第一个问题,在过去的一周里我一直试图解决这个问题,但是我被卡住了 我将一个字节数组从C++中传递给C++。C++ DLL只需要 >>强>数据,没有从C++到C的传递。 在C++方面: void bytefunc(unsigned char* tex, int length){ for(int i=0;i<length;i++){ a[i]=b[i]; //definition and memory for a is al
我将一个字节数组从C++中传递给C++。C++ DLL只需要<强> >>强>数据,没有从C++到C的传递。 在C++方面:
void bytefunc(unsigned char* tex, int length){
for(int i=0;i<length;i++){
a[i]=b[i]; //definition and memory for a is already allocated
}
}
这段代码在Windows机器上运行得非常好,无论我运行它多长时间。我们最近将应用程序迁移到android上,应用程序在随机时间崩溃,事实上有时根本不会崩溃。经过数小时的调试,我已经确定这段代码是罪魁祸首,因为SIGSEGV总是在这里。我做错什么了吗?有没有其他方法可以做到这一点?谢谢 您应该在C端定义封送处理,以确保正确序列化数据。进一步阅读:当它崩溃时,您是否检查了
byteArr
和length
的值?
[DllImport ("dll")];
private static extern void bytefunc(byte[] byteArr, int length);
........
bytefunc(barr,len) //all the variables are set properly before calling