#ifdef Directive

This page was translated by a robot.

The directive initiates a conditional compilation #ifdefin the same way as the #ifdirective . However, the preprocessor checks here whether the specified macro exists.






Big number: 99999999
#include <stdio.h>
#define THE_BIG_NUMBER 99999999

int main(){
  #ifdef THE_BIG_NUMBER
    printf("Big number: %d\n", THE_BIG_NUMBER);
  #else
    printf("No Big number defined.\n");
  #endif
  return 0;
}

Details

The #ifdefdirective does the same thing as #if defined.

The #ifdefdirective does not evaluate the expression to be checked, only checks its existence. If the specified macro exists, the condition is met and the code within the block is compiled. Otherwise it is completely discarded.