Strange compiler errors [solved]

SGDK only sub forum

Moderator: Stef

Post Reply
twosixonetwo
Very interested
Posts: 58
Joined: Tue Feb 25, 2014 3:38 pm

Strange compiler errors [solved]

Post by twosixonetwo » Sat Aug 02, 2014 8:22 am

While changing my code I encountered the following situation:
Let's say I have this code:

Code: Select all

void handleJoyEvent(u16 joy, u16 changed, u16 state);

u8 readVDP60hz()
{
	return (*((u16*)(0xC00004)))&0x1;
};

int main()
{
    // [...]

    JOY_setEventHandler(handleJoyEvent);
    // [...]
}
//no declaration of handleJoyEvent follows
Instead of complaining that I don't declare what handleJoyEvent does, I get these Errors:

Code: Select all

C:/sgdk/lib/libmd.a(main.o): In function `readVDP60hz':
main.c:(.text+0x178): multiple definition of `readVDP60hz'
out/src/main.o:main.c:(.text+0xf8): first defined here
C:/sgdk/lib/libmd.a(main.o): In function `main':
main.c:(.text+0x184): multiple definition of `main'
out/src/main.o:main.c:(.text+0x104): first defined here
C:/sgdk/bin/ld: Warning: size of symbol `main' changed from 232 in out/src/main.
o to 330 in C:/sgdk/lib/libmd.a(main.o)
make: *** [out/rom.out] Error 1
I don't have multiple declarations of those functions, neither in main.c nor in multiple files. If I remove the JOY_setEventHandler-call the code compiles fine (without warnings).

Does someone know why that is? Might this be due to my makefile or is this unavoidable?
Last edited by twosixonetwo on Wed Aug 06, 2014 10:21 am, edited 1 time in total.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sat Aug 02, 2014 9:25 am

I think there is something really wrong in your makefile, i guess you don't use the one included in SGDK ?

twosixonetwo
Very interested
Posts: 58
Joined: Tue Feb 25, 2014 3:38 pm

Post by twosixonetwo » Sat Aug 02, 2014 12:50 pm

Well, the newest makefile doesn't work for me since I've got the sega.s and the rom_head.c in my src folder:

Code: Select all

C:\sgdk\projects\SVPDemo>%GDK_WIN%\bin\make -f makefile.gen
make: *** No rule to make target `C:/sgdk/src/boot/sega.s', needed by `src/boot/sega.s'.  Stop.
If I change

Code: Select all

$(SRC)/boot/sega.s: $(LIBSRC)/boot/sega.s
	$(MKDIR) -p $(SRC)/boot
	$(CP) $< $@

$(SRC)/boot/rom_head.c: $(LIBSRC)/boot/rom_head.c
	$(MKDIR) -p $(SRC)/boot
	$(CP) $< $@
to

Code: Select all

$(SRC)/boot/sega.s: $(SRC)/boot/sega.s
	$(MKDIR) -p $(SRC)/boot
	$(CP) $< $@

$(SRC)/boot/rom_head.c: $(SRC)/boot/rom_head.c
	$(MKDIR) -p $(SRC)/boot
	$(CP) $< $@
the compilation works AND I am getting the compiler error I've described above :?

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sat Aug 02, 2014 5:50 pm

You have an extra ";" following the close brace for readVDP60hz().

twosixonetwo
Very interested
Posts: 58
Joined: Tue Feb 25, 2014 3:38 pm

Post by twosixonetwo » Sat Aug 02, 2014 7:25 pm

Yes, that's unnecessary, doesn't create any problems though. (IIRC) it's merely an empty statement.
I removed it and the strange compiler message remains...

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sat Aug 02, 2014 10:03 pm

Did you removed the sega.s file from the base SGDK folder ?
If yes you should not do it, the new makefile will just copy the sega.s from the original SGDK folder then you can freely modify it if you want...
From your error it looks like you removed the original sega.s file.

twosixonetwo
Very interested
Posts: 58
Joined: Tue Feb 25, 2014 3:38 pm

Post by twosixonetwo » Mon Aug 04, 2014 11:35 am

Ahh... well now I realize what your change meant. I have never written a makefile from scratch and wasn't really aware of how the change was supposed to work.

So, I now use the newest makefile (https://code.google.com/p/sgdk/source/b ... n194&r=194) and the strange compiler errors are still there.

If I have a little more time I might narrow it down to a test case and see if it has to do with the implementation of JOY_setEventHandler, compiler version or mistakes in my code ;)

twosixonetwo
Very interested
Posts: 58
Joined: Tue Feb 25, 2014 3:38 pm

Post by twosixonetwo » Wed Aug 06, 2014 10:21 am

Case closed. Updated sgdk from 0.95 to 0.96d and the strange errors went away. Sorry for the confusion caused. :oops:

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Aug 06, 2014 12:03 pm

Glad to hear you fixed it :)

Post Reply