Incorrect of #define if deep under uncertain #if
"The C preprocessor chainsaw"
Brought to you by:
imkinghan
$ coan --version
coan, version 6.0.1 for 64 bit Unix/Linux(built Sep 15 2014,18:49:36)
Symbol gets defined through #define if the inner most #if is true, even though the
Example to reproduce the bug
$ cat bug2.c
#ifdef THIS_MAY_NOT_BE_DEFINED // unknown
#ifdef A // true - A is defined
#define B // BUG! B gets defined, but should NOT,
// because outer if is uncertain!
#endif
#endif
#ifdef B // this #ifdef line is incorrectly stripped
// because B got defined at line 3
this line MUST remain enclosed inside #ifdef!
#endif
$ coan source -DA bug2.c
#ifdef THIS_MAY_NOT_BE_DEFINED // unknown
#define B // BUG! B gets defined, but should NOT,
// because outer if is uncertain!
#endif
this line MUST remain enclosed inside #ifdef!