T
Tony Burden
Recently I've run into a couple of hard-to-track bugs because I have
a section of conditionally compiled code using a symbol which hasn't
been defined. For example, take the trivial case of this "program"
-------
#define XYZZY 1
main() {
#if XYZZU
printf("xyzzy\n");
#else
printf("plugh\n");
#endif
}
------
Now, obviously that XYZZU was supposed to be an XYZZY, and I wanted to
conditionally compile the first piece of code, not the second. But when
I compile this, it doesn't even give me a friendly warning, and just
assumes XYZZU is 0. (Which, I understand, is in accordance with ANSI-
defined behavior.)
Now, my question is how other people avoid these same kinds of idiotic
mistakes? Even if I put in "#if !defined(XYZZY)..." type things for
every define, it still wouldn't catch all typos. There should be some
way to avoid this idiotic kind of error...
a section of conditionally compiled code using a symbol which hasn't
been defined. For example, take the trivial case of this "program"
-------
#define XYZZY 1
main() {
#if XYZZU
printf("xyzzy\n");
#else
printf("plugh\n");
#endif
}
------
Now, obviously that XYZZU was supposed to be an XYZZY, and I wanted to
conditionally compile the first piece of code, not the second. But when
I compile this, it doesn't even give me a friendly warning, and just
assumes XYZZU is 0. (Which, I understand, is in accordance with ANSI-
defined behavior.)
Now, my question is how other people avoid these same kinds of idiotic
mistakes? Even if I put in "#if !defined(XYZZY)..." type things for
every define, it still wouldn't catch all typos. There should be some
way to avoid this idiotic kind of error...