Assignment makes integer from pointer without a cast [-Wint-conversion

Addon picture Addon · Jan 17, 2016 · Viewed 31.3k times · Source

I really don't understand why I have such error knowing that tmp and key are the same type and size.

uint8_t key[8] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07};

void change() {

    int i;
    uint8_t *tmp[8];

    for(i=0; i<8; i++){
        tmp[i] = key[(i+3)%8];
    }
}

This produces:

warning: assignment makes integer from pointer without a cast [-Wint-conversion

Answer

Sourav Ghosh picture Sourav Ghosh · Jan 17, 2016

tmp and key are the same type

NO. They are not. They both are arrays, but the datatype is different. One is a uint8_t *array, another is a uint8_t array.

Change

 uint8_t *tmp[8];

to

uint8_t tmp[8] = {0};