#undef Directive

This page was translated by a robot.

The #undefdirective discards a previous macro definition.





Number: 42


Number: 42
#include <stdio.h>

int main(){
  #define NUMBER 42
  printf("Number: %d\n", NUMBER);
  #undef NUMBER
  #define NUMBER (6 * 9)
  printf("Number: %d\n", NUMBER);
  return 0;
}

Details

After using the #undefdirective, the macro can be redefined with the #definedirective . Without the #undefdirective, the compiler would at least issue a redefined warning.

If the specified macro was not defined at all, the #undefdirective is simply ignored.