C enum type warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

(sorry to send this email again, I pressed an emacs key combination on
gmail by error then the email was sent, and the email was not
complete)
I have been looking for a way to detect a programming error like the
following with gcc:

enum foo_e {
 ZERO,
 ONE,
  TWO
};

int main(void) {
  enum foo_e bar;
  bar=ZERO; // correct use of bar
  bar=50; //possible incorrect use of bar
  ....
}

I couldn't find a way to get a warning message from gcc for the second
use of bar (I tried -Wall and -Wswith-enum). Is there a way to get
warning out of this? I played around with splint and it can detect
this type of programming error, the problem with splint is that only
parses C89 code and it gives for example parse errors for variable
declarations inside of for expresions. Also splint seems to be
unmaintained nowadays.

Thanks and all the best,
Federico Ruiz Ugalde

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux