#135083 - ShannonB - Fri Jul 20, 2007 3:56 am
So in my ongoing quest, aided by TONC, to develop Good Programming Habits (TM) from the start, I'm facing some issues.
I used to #include my image data in my main.cpp file before compiling. This, we have concluded, is a Bad Thing (TM).
I have 3 image data files to deal with:
test.map.c
test.raw.c
test.pal.c
So after reading up, I did the following.
1) commented out the #includes in my main.cpp
2) added the files to be compiled separately in my makefile
3) Declared the arrays that are contained in the external files, in my main.cpp just before my function prototype declarations
4) Commented out the declarations of the array types in the external files (since they're already declared in my main.cpp right? If I declare them twice I get an error?)
like this...
I did the other 2 in the same way, so I'm not going to waste space and copy them here.
My c++ knowledge may be lacking, but I'm not sure how, after I've declared them, the data actually gets put into them before I use them in my code. However I can't seem to find any further steps.
When I compile I get the following error.
I have a feeling my problem might be with the makefile, but I'm really not sure. I guess the next thing is to go and do some more work on learning about makefiles?
Oh, and this was compiling and working correctly before I attempted this.
_________________
"Do you know what the chain of command is? It's the chain I get and beat you with until you understand who's in rutting command here!" -Jayne Cobb
I used to #include my image data in my main.cpp file before compiling. This, we have concluded, is a Bad Thing (TM).
I have 3 image data files to deal with:
test.map.c
test.raw.c
test.pal.c
So after reading up, I did the following.
1) commented out the #includes in my main.cpp
Code: |
//include the sample tileset/map //#include "test.pal.c" //#include "test.raw.c" //#include "test.map.c" |
2) added the files to be compiled separately in my makefile
Code: |
# --- Project details --- PROJ := eclipgba EXT := gba CFILES := main.cpp test.map.c test.pal.c test.raw.c COBJS := $(CFILES:.cpp=.o) OBJS := $(COBJS) |
3) Declared the arrays that are contained in the external files, in my main.cpp just before my function prototype declarations
Code: |
// ===declarations === extern const unsigned short test_Map[1024]; extern const unsigned short test_Palette[256]; extern const unsigned char test_Tiles[28416]; |
4) Commented out the declarations of the array types in the external files (since they're already declared in my main.cpp right? If I declare them twice I get an error?)
like this...
Code: |
/* * 32x32 map data */ //const unsigned short test_Map[1024] = { 0x0000, 0x0001, 0x0001, 0x0002, 0x0000, 0x0001, 0x0001, 0x0003, ...etc |
I did the other 2 in the same way, so I'm not going to waste space and copy them here.
My c++ knowledge may be lacking, but I'm not sure how, after I've declared them, the data actually gets put into them before I use them in my code. However I can't seem to find any further steps.
When I compile I get the following error.
Code: |
make -f makefile build makefile:41: target `test.map.c' doesn't match the target pattern makefile:41: target `test.pal.c' doesn't match the target pattern makefile:41: target `test.raw.c' doesn't match the target pattern test.map.c:5: warning: data definition has no type or storage class test.pal.c:2: warning: data definition has no type or storage class test.raw.c:5: warning: data definition has no type or storage class d:/devkitpro/devkitarm/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/bin/ld.exe: address 0x301d890 of eclipgba.elf section .data is not within region iwram collect2: ld returned 1 exit status make: *** [eclipgba.elf] Error 1 |
I have a feeling my problem might be with the makefile, but I'm really not sure. I guess the next thing is to go and do some more work on learning about makefiles?
Oh, and this was compiling and working correctly before I attempted this.
_________________
"Do you know what the chain of command is? It's the chain I get and beat you with until you understand who's in rutting command here!" -Jayne Cobb