Cannot initialize a parameter of type "const unsigned char *" with an rvalue of type 'value_type *' (aka char*)
16,264
The const is not a problem, but you need to cast the pointer - this isn't recommended generally but if you don't have another choice, you can do one of the following
char *a = buffer->data();
const unsigned char *b= reinterpret_cast<unsigned char *>(a);
or plain C style
const unsigned char *b= (const unsigned char *)(a);
Author by
Geo Paul
Updated on July 14, 2022Comments
-
Geo Paul almost 2 years
I get an error "Cannot initialize a parameter of type "const unsigned char *" with an rvalue of type 'value_type ' (aka char)" in the following lines.
image->initWithImageData(&(buffer->front()),buffer->size());
buffer is of type
std::vector<char> *buffer
and the above error in on
&(buffer->front()
does anybody know how to fix it?