Re: [Tuxnes-devel] *.h: extern int function() VS int function().
Brought to you by:
tmmm
From: Jason D. S. <jd...@us...> - 2004-08-24 20:11:32
|
Jason Dorje Short wrote: > Mike Mestnik wrote: > >> For functions maby not, however this is what I got... >> /usr/bin/ld: Warning: size of symbol `emulators' changed from 44 in >> controller.o to 132 in emulator.o >> /usr/bin/ld: Warning: size of symbol `renderers' changed from 36 in >> controller.o to 252 in renderer.o >> /usr/bin/ld: Warning: size of symbol `sounders' changed from 28 in emu.o >> to 84 in sounder.o >> >> So things that are extern should stay(and be) extern. > > Variables have to be extern. Functions need not be. "Size of symbol changed" => this may actually be a bug. I've seen this before when some header files aren't included right. Say there is stdbool.h with: typedef bool char #define HAVE_BOOLEAN Say you've got a header tuxtype.h with #ifndef HAVE_BOOLEAN # define bool int #endif struct var { bool p, q; }; extern struct var var; Now you have one tuxtype.c file: #include <stdbool.h> #include "tuxtype.h" struct var; and another func.c file: #include "tuxtype.h" int func() { var.p = TRUE; var.q = FALSE; } now func() will completely not work because it thinks bool is an int, whereas in the declaration in tuxtype.c it is a char. This is almost impossible to track down. But it _could_ give an error message like the one you have above. The solution of course is that <stdbool.h> must be included in tuxtype.h. I think leaving the extern declaration out of the variable may give an error, but it shouldn't be the one you got... jason |