jeudi 2 juillet 2015

Why does 'typeof enum constant' generate a warning when compared to a variable of enum type?

I have the following code.

typedef enum {FOO, BAR} Baz;

int main()
{
    Baz f1 = FOO;
    typeof(FOO) f2 = FOO;
    return (f1 == f2);
}

My compilation using gcc -Wextra foo.c generates a warning saying

foo.c: In function ‘main’:
foo.c:7:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 return (f1 == f2);
             ^

My gcc version

gcc --version
gcc (Ubuntu 4.9.2-10ubuntu13) 4.9.2

How can I fix this problem?

Aucun commentaire:

Enregistrer un commentaire