Can anybody please tell me which flag I have to use in order to make gcc ignore the 'comparison between signed and unsigned integer expressions' warning message.
while comparing a>b where a is unsigned int type and b is int type, b is type casted to unsigned int so, signed int value -1 is converted into MAX value of unsigned**(range: 0 to (2^32)-1 )** Thus, a>b i.e., (1000>4294967296) becomes false. Hence else loop printf("a is SMALL!
Sure, comparisons between signed and unsigned would be slower, but their result would be more correct in some sense. @Nawaz Your bottom line conclusion is incorrect, unfortunately: if the signed type can contain the unsigned type, the unsigned will be converted to the signed type and not the opposite.
The term "unsigned" in computer programming indicates a variable that can hold only positive numbers. The term "signed" in computer code indicates that a variable can hold negative and positive values. The property can be applied to most of the numeric data types including int, char, short and long.
A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]. An unsigned integer is a 32-bit datum that encodes a nonnegative integer in the range [0 to 4294967295]. The signed integer is represented in twos complement notation.
gcc -Wno-sign-compare
But you should really fix the comparison it's warning you about anyway.
Here's what worked for me, using the gcc compiler in Code::Blocks. In the compiler settings, click the "Compiler Settings" tab, then choose "Other Compiler Options. Type in -Wno-sign-compare The warning -Wsign-compare can be negated by adding "-Wno" as a prefix. In fact warnings can be ignored by adding -Wno- to the warning code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With