I am modifying some code and there is a #define with no value. It looks
like its used for testing.There are several #ifdef references.Is this
ignored if there is no value assigned?
No, a #define with no value defines the value as 0 but marks it as
defined.
Be careful using the variable in preprocessor expressions:
#define FOO
#define BAR 1
/* BAZ is not defined at all */
then taking each of the below individually:
#ifdef FOO /* this is true */
#ifdef BAR /* this is true */
#ifdef BAZ /* this is false */
#if FOO /* this is false because FOO's value 0 is substituted */
#if BAR /* this is true because BAR's value 1 is substituted */
#if BAZ /* this is false because all symbols remaining after
preprocessing have 0 substituted for them, so
0 is put in in place of BAZ */
#if defined(FOO) /* this is true */
#if defined(BAR) /* this is true */
#if defined(BAZ) /* this is false */
#if !FOO /* this is true because FOO is 0 and !0 is true */
#if !BAR /* this is false because BAR is 1 and !1 is false */
#if !BAZ /* this is true because remaining symbols have 0
substituted for them, making this !0 which is true */