2
votes

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?

1
unsigned char* and char* are 2 different types. could you change buffer to std::vector<unsigned char> *bufferJarod42

1 Answers

3
votes

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);