ali kiani
ali kiani

Reputation: 887

Error "expression must be a modifiable lvalue" produced

I get top error in below code in line channels[0][x] = luma_lut[row[x]]; :

typedef struct {
    const unsigned char *const *const row_pointers;
    float gamma_lut[256];
} image_data;
void convert_image_row_gray(const float * __restrict channels[], const int num_channels, const int y, const int width, void * user_data)
{
    image_data *im = (image_data*)user_data;
    const unsigned char *row = im->row_pointers[y];
    const float *luma_lut = im->gamma_lut; // init converts it

    for (int x = 0; x < width; x++) {
        channels[0][x] = luma_lut[row[x]];
    }
}

What's wrong in this code?

Upvotes: 0

Views: 255

Answers (1)

AnT stands with Russia
AnT stands with Russia

Reputation: 320421

channels is declared with const float ** type, which means that channels[i][j] is an lvalue of const float type. You are not allowed to change const float lvalues - they are const.

Given this declaration of channels you can change channels itself, you can change channels[i], but you cannot change channels[i][j].

Upvotes: 1

Related Questions