This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Wrong sign of enum

I have a simple code like this:


typedef enum
{
  N1 = 1,
  N2 = 2

} EnumType;

int main(void)
{

    EnumType A = N1;

    if( A >= 0 )
        return 1;

    return 0;
}


Comparison with zero gives me warning "#186-D: pointless comparison of unsigned integer with zero".

I then go to project options and check "Enum container always int".

If this code was in *.cpp file - everything is fine, warning goes away (as it should).
But if it's in *.c file - warning is still there!

Compiler key --cpp has the same effect.

This behaviour is very annoying, actually, because I have an entire library filled with such comparisons (and warnings).

Can anyone please tell me, how to remove this very annoying warning and is it a bug or not?

I'm using ARM Keil 4.72.

P.S. I know that I can just disable this warning with a compiler suppressing option (and that's evil by itself) or with pragma but that is not very good solution.