Search code examples
clpceeprom

EEPROM stroe and Initialization makes pointer from integer without a cast


I get warning:

Initialization makes pointer from integer without a cast

This is my code:

case 4:
{
    uint8_t* adr = 12;
    writeEEPROM((uint8_t *) adr, &z, sizeof(z));
}

writeEEPROM have:

void writeEEPROM( uint8_t* eeAddress, uint8_t* buffAddress, uint32_t byteCount ){....

Where is my problem.

And maybe question 2: it is possible if I send union address into a function writeEEPROM?


Solution

  • The problem is the part of the code that makes a pointer from integer without a cast. Change to uint8_t* adr = (uint8_t*)12;

    it is possible if I send union address into a function writeEEPROM?

    Yes, you can write any kind of data. However, mind struct/union padding and alignment. It is common that the EEPROM has different alignment requirements than RAM variables.