cgame-boy-advancedevkitpro

invalid initializer in gba


im Lino, im new on this community. basically, im trying to save data into the GAMEPAK_RAM of the GBA, and the pointer dont work. the code line is this:

#define GAMEPAK_RAM ((volatile uint8_t*)0x0E000000)

and the error is this:

    In file included from source/main.c:2:0:
source/OpenEngine.h:8:21: error: invalid initializer
 #define GAMEPAK_RAM ((volatile uint8_t*)0x0E000000)
                     ^

someone can help me? if other info is needed, please tell me


Solution

  • unsigned short *SaveMemory[0xFFFF] = GAMEPAK_RAM;
    

    This is the same as:

    unsigned short *SaveMemory[0xFFFF] = ((volatile uint8_t*)0x0E000000);
    

    SaveMemory is an array and ((volatile uint8_t*)0x0E000000) is a pointer. You can't set an array equal to a pointer, hence the error.