我需要创建数组:
const UInt8 *pixels[3] = { yuvFrame.luma.bytes, yuvFrame.chromaB.bytes, yuvFrame.chromaR.bytes };
但是Xcode向我显示错误:
Cannot initialize an array element of type 'const UInt8 *' (aka 'const unsigned char *') with an rvalue of type 'const void *'
我将C ++代码与Objective-C混合在一起。那么我该如何解决呢?我需要这个常量UInt8 * pixels [3]。有什么建议么?
最佳答案
尝试以下初始化
const UInt8 *pixels[3] =
{
( const UInt8 * )yuvFrame.luma.bytes,
( const UInt8 * )yuvFrame.chromaB.bytes,
( const UInt8 * )yuvFrame.chromaR.bytes
};
在C ++中,没有从
void *
类型的指针到任何其他类型的对象的指针的隐式转换。关于c++ - Objective-C + Cpp右值和数组,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29072317/