3
votes

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

2

2 Answers

2
votes

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};
1
votes

Not clear what you want here but if you want tmp[x] to reflect the value in key[y] then

tmp[i] = &key[(i+3)%8]; /* tmp[i] now points at key[ (i+3)%8];
// key[3] = 5;    /* These two lines modify the same memory */
// (*tmp[0]) = 5; /*                                        */

Otherwise if you want tmp to be separate, then ...

 uint8_t tmp[8];  /* change type to be non-pointer. */