Page 1 of 1

Strange GCC warnings

Posted: Sat Apr 08, 2006 8:35 pm
by Candamir
I recently switched to GCC 4.1.0 (under Cygwin, but shouldn't be relevant, though) and now my kernel won't compile because of the warnings I get (-Wall -Werror set). All those warnings are of the same format:

Code: Select all

[filename]:[line]: warning: pointer targets in (passing argument [argnum] of [funcname]/initialization) differ in signedness.
I checked the warnings and they all refer to the seemingly incorrect use of some variables of type unsigned char * (only pointers, unsigned chars work normally). I also checked the funcion parameter lists and there isn't any error at all, both are unsigned...

I think that this is a new feature introduced in GCC 4.x, because I googled about it and found some information in GNOME mailing-lists and they had the same problem, but they managed to fix it (and didn't post the solution >:( ;)). Has anyone else been migrating to a newer GCC version recently and found himself in front of this problem?

Thanks

Re:Strange GCC warnings

Posted: Sun Apr 09, 2006 5:33 am
by durand
Dunno but if it's an signedness issue and you're using unsigned char*, try using just a char* ... or make sure you're casting correctly to the right sign.

GCC 4.0 adds a lot of additional checks and warnings. It's quite nice... it shows you exactly where you have the potential for logical mistakes.

Re:Strange GCC warnings

Posted: Sun Apr 09, 2006 12:36 pm
by Candamir
It worked! Just used char * variables when using strings. But anyway, /how/ did this happen? Why a warning about this? unsigned ints/longs didn't make any trobule at all...

Re:Strange GCC warnings

Posted: Sun Apr 09, 2006 1:20 pm
by Candy
Because an unsigned int isn't a signed int and they should be incompatible. You can also explicitly cast them or just use unsigned char *'s everywhere. Or do as I do, define a new type (such as the standard uint8_t or my own byte) to refer to an unsigned char.

Re:Strange GCC warnings

Posted: Sun Apr 09, 2006 9:26 pm
by Candamir
Thank you all.

If you noticed, I'm fighting with my tools lately ;)

Candamir