I wrote a library in C that will now be used in the integrated processor board. I need to reduce the printing of memory folders, so that there is a change in the return type of some functions from int to char (used only for the error flag).
Changing the return type, but not changing the return variable, does not raise a warning. Is there any way to install this in gcc as I want to make sure that I have caught all instances.
char processSomething (SomeType *something) { int result = 0; ... do stuff ... return result; }
thanks
June 19: I added -Wconversion, which highlighted some interesting things. Two questions. One of my functions is taking a two-character hexadecimal string and converting to decimal using
char decimal;
decimal = hexstring [0] - '0' << 4 + hexstring [1] - '0';
he complains about converting from int to char and from what I can compile, these are the '-', '+' and '<<operators all seem to be implicitly converted to int. Is this correct or am I interpreting the warning incorrectly. Or is there a better way to do this?
Also, when using strtol in int (complains about 'long int' for 'int'), but I can guarantee that the value will not exceed even a short int in size, is this safe for typecast? As in the case of truncating extra (and, hopefully, zero bytes) long? Or does it depend on the essence?
thanks
source share