While I'm aware this is valid C not to differentiate between enum types.
GCC does have -Wenum-compare (which I'm using) and works as expected.
I tried using -Wconversion but this doesn't make any difference.
How can assignments and arithmetic operators (+/-/&/|... etc) also generate warnings? (assignment, or and... etc)
{
enum Foo f = SOME_VALUE;
enum Bar b = SOME_OTHER_VALUE;
if (f != b) {
/* this warns! */
}
f = b; /* <-- how to warn about this? */
f |= b; /* .. and this? */
}
Notes:
- Switching to C++ is not an option (as suggested in other answers).
- This question is closely related, however its not a duplicate because it's about passing arguments instead of arithmetic.