JeffRuLz/Celeste-Classic-GBA

Multiple Definitions of MAP_DATA and FLAGS_DATA when compiling

Closed this issue · 2 comments

Hey. When I was trying to compile with devkitpro I kept getting an error stating that there were multiple definitions of FLAG_DATA and MAP_DATA.

flags.c
main.c
pico8.c
map.c
linking cartridge
/opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/ld: main.o:/home/whatever/Celeste-Classic-GBA/src/pico8.h:13: multiple definition of `MAP_DATA'; flags.o:/home/whatever/reference/Celeste-Classic-GBA/src/pico8.h:13: first defined here
/opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/ld: main.o:/home/whatever/Celeste-Classic-GBA/src/pico8.h:10: multiple definition of `FLAGS_DATA'; flags.o:/home/whatever/Celeste-Classic-GBA/src/pico8.h:10: first defined here
[REPEATED 3 TIMES]

I did a quick hack to correct it:

  • Copied the contents of flags.c and map.c into main.c
  • Moved the fget() definition to main.c
  • Commented out MAP_DATA and FLAGS_DATA in pico8.h

After that everything compiled fine.

I just learned a bit more C and I think you can fix it by adding extern to FLAGS_DATA and MAPS_DATA in pico8.h.

#define FLAGS_SIZE 256
extern const unsigned char FLAGS_DATA[FLAGS_SIZE];

#define MAP_SIZE 8192
extern const unsigned short MAP_DATA[MAP_SIZE];

Thanks for the heads-up!