c - How to warn when assigning or performing arithmetic with different enum types in GCC? -


while i'm aware valid c not differentiate between enum types.

gcc have -wenum-compare (which i'm using) , works expected.

i tried using -wconversion doesn't make difference.

how can assignments , arithmetic operators (+/-/&/|... etc) generate warnings? (assignment, or and... etc)

{     enum foo f = some_value;     enum bar b = some_other_value;      if (f != b) {         /* warns! */     }      f = b;  /* <-- how warn this? */     f |= b;  /* .. , this? */  } 

notes:

  • switching c++ not option (as suggested in other answers).
  • this question closely related, not duplicate because it's passing arguments instead of arithmetic.

according this answer, clang supports desired behavior.

there some approaches emulate typed enums in c, seem have various limitations.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

Ruby Google Calendar Integration Watch Event / Push Notification -