C enum type warning
Federico Ruiz
memeruiz@gmail.com
Mon Jun 29 23:00:00 GMT 2009
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
More information about the Gcc-help
mailing list