What is the difference (if any) between the next two preprocessor control operations.
#if
and
#ifdef
You can demonstrate the difference by doing:
#define FOO 0 #if FOO // won't compile this #endif #ifdef FOO // will compile this #endif
#if checks the value of a character, and #ifdef checks for the presence of a character (regardless of its value).
#ifdef FOO
is a shortcut for:
#if defined(FOO)
#if can also be used for other tests or for more complex preprocessor conditions.
#if defined(FOO) || defined(BAR)