gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Multiple Definitions

#77139 - CyberSlag5k - Tue Mar 28, 2006 5:00 pm

I've split my project into separate files so that I may compile my interrupt request handler in ARM mode, rather than thumb. As such, I have included gba.h in both files. However when I go to link everything together, I am getting multiple definition errors for stuff like OBJPaletteMem and OAMData.

I don't absolutely need to have gba.h included in my interrupt handling file, but is it possible to include the file in both of my files and not have redefinition problems?

Thanks in advance!
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...

#77161 - sajiimori - Tue Mar 28, 2006 7:59 pm

Those arrays need to be declared extern and defined once in any of your .c files. Otherwise it will create them once for every time you include the header.

#77189 - CyberSlag5k - Wed Mar 29, 2006 3:55 am

That did it. Thank you.
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...