PDA

View Full Version : chars and unsigned chars: compiler warnings



Officedog
10-28-2008, 10:14 AM
I'm experimenting with making a GUI button. I have a C struct to contain various attributes of the button such as position, dimensions, and the label.

The storage for the label I have declared as a char array:

char string[20];


The compiler is complaining (warnings rather than failures) and I'm not sure whether the complaints mean that there is a fundamental problem which will bite me later.

The issue seems to be that when I call typical C functions such as:


strcpy(pButtonData->buttonLabel, "Label");


There is no problem, however, when I pass the char string[ ] to some openGL functions such as:

stringLength = glutBitmapLength(font, string);

I get a compiler warning refering to a difference in "signedness" of the argment. I do understand that there are unsigned chars and signed chars in C.... but...

I did try changing the struct declaration to:

unsigned char string[ ];

However, now the compiler complains on behalf of the C functions like strcpy. I also tried throwing in a cast to the variables but am not sure I really understand this well, and in any case it did not seem to help.


I hope this all makes sense. Can anyone shed some light on this for me?

Thanks in advance