#74619 - aik6980 - Mon Mar 06, 2006 1:08 pm
Here is my problem, I want to separate the src file for functions, and they are linking to the same header that contained some global variable.
here is my error message;
and here is my header code
my functions, struct and #define work, but not for the global var
anyidea??
please help
thank a lot
here is my error message;
Code: |
mygba.o(.data+0x0): multiple definition of `OAM' main.o(.data+0x0): first defined here mygba.o(.data+0x4): multiple definition of `OBJPalMem' main.o(.data+0x4): first defined here mygba.o(.data+0x8): multiple definition of `FrontBuffer' main.o(.data+0x8): first defined here mygba.o(.data+0xc): multiple definition of `OAMData' main.o(.data+0xc): first defined here mygba.o(.data+0x10): multiple definition of `sprites' main.o(.data+0x10): first defined here collect2: ld returned 1 exit status make: *** [main.elf] Error 1 |
and here is my header code
Code: |
#ifndef MYGBA_H #define MYGBA_H //include file ... //***TYPE_COMMON*** ... //***GLOBAL*** extern u16* OAM = (u16*)0x7000000; extern u16* OBJPalMem = (u16*)0x5000200; extern u16* FrontBuffer = (u16*)0x6000000; extern u16* OAMData = (u16*)0x6010000; //create array of sprites extern OAMEntry sprites[128]={0}; .. #ifndef MYGBA_C //***FUNCTION*** //function to copy our Sprite --> OAMMemory void CopyOAM(void); //Set sprites off screen void InitSprites(void); //Update during VBlank void WaitForVSync(){ while(REG_VCOUNT != 160); } #endif #endif |
my functions, struct and #define work, but not for the global var
anyidea??
Code: |
#define MYGBA_C //include #include "mygba.h" //function //function to copy our Sprite --> OAMMemory void CopyOAM(void){ u16 loop=0; u16* temp=(u16*)sprites; //point to sprites for(loop=0;loop<128*4;loop++) OAM[loop] = temp[loop]; //need to use temp, because we want to pack each //data to 16 bits first before write down to OAMMemory } //Set sprites off screen void InitSprites(){ u16 loop=0; for(loop=0;loop<128;loop++){ sprites[loop].attribute[0]=SCRWIDTH; //y >159 sprites[loop].attribute[1]=SCRHEIGHT; //x >239 } } |
please help
thank a lot