Path: chuka.playstation.co.uk!scea!peter_alau@playstation.sony.com From: "Antony Arciuolo" Newsgroups: scea.yaroze.programming.gnu_compiler Subject: Re: Linking Date: Fri, 3 Dec 1999 08:33:31 -0500 Organization: SCEA News Server Lines: 97 Message-ID: <828gl1$jq6@scea> References: <8275bv$jq3@scea> <38473a31.380863452@news.playstation.co.uk> Reply-To: "Antony Arciuolo" NNTP-Posting-Host: 209.166.42.130 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 I think BOTH should work because I got the #ifndif in there. So any 2nd include of BG.h should be completely skipped, otherwise I'd get multiple definitions for each and every file. but nope, just on statically init'ed arrays. - Tony Steven Osman wrote in message news:38473a31.380863452@news.playstation.co.uk... > Antony, > > I would recommend using something to the effect of: > > extern u_short Layout1[6]; > in the .h file, > > and putting the code you have written below in bg.c. I am guessing > that you #include bg.h in both main.c and bg.c, correct? > > The problem is that each time a .c file #includes bg.h, they will > define a new "copy" of Layout1, hence, your error. > > As for your latter comment, I'm not certain why > u_short Layout1[6]; > would work. To me, that looks like you are still redefining it. > Maybe it has something to do with the way the linker works/ including > statically initialized variables, and all...? (Still, I don't think > EITHER should work). > > On Thu, 2 Dec 1999 20:26:11 -0500, "Antony Arciuolo" > wrote: > > >I have an array to describe a layout (index) for a GsBG. > > > >I want to explicitly define it in the header of a BG module: > > > >#ifndef BG_H > >#define BG_H > > > >u_short Layout1[] = > > >GsCELLtransparentCell, GsCELLtransparentCell, > >GsCELLtransparentCell, GsCELLtransparentCell, > >GsCELLtransparentCell, GsCELLtransparentCell > >}; > > > >... > >#endif > > > >Now I want to compile using this makefile > > > > > >PROGRAM = test.pxe > >PXE_ADDR = 80140000 > > > ># To Optimize use -O3 instead of -g > >OPTIONS = -c -g > >LINKER = -Xlinker -Map -Xlinker mapfile.map -Xlinker -Ttext -Xlinker $(PXE_ADDR) > >DEPENDENCIES = bg.o main.o > > > >all: $(PROGRAM) > > > >$(PROGRAM): $(PROGOBJ) $(DEPENDENCIES) > > gcc $(LINKER) $(DEPENDENCIES) -o $(PROGRAM) > > > >main.o: main.c mainTIMS.h Levels.h > > gcc $(OPTIONS) main.c > > > >bg.o: bg.c bg.h Levels.h > > gcc $(OPTIONS) bg.c > > > >The problem is: > > > >gcc -Xlinker -Map -Xlinker mapfile.map -Xlinker -Ttext -Xlinker 80140000 bg.o main.o -o test.pxe > >main.o(.data+0x0): multiple definition of `Layout1' > >bg.o(.data+0x0): first defined here > >make.exe: *** [test.pxe] Error 1 > > > >How can I solve this? It just does not seem to me that it is being defined twice, and if I redeclare Layout1 as: > > > > > >u_short Layout1[6]; > > > >Everything is fine. Why? > > > >- Tony > > > > > > > > >