Introduction
In the C programming language, #undef is a directive that can help you remove all the definitions for the given macro name or any other constant defined using the #define directive. This is a part of the preprocessor directive because it is called by the compiler automatically before actual compilation begins. Before the compilation process of the C program starts, the compiler source code is processed, and that's why this process is named preprocessing. All the different commands used for the preprocessor are known as the preprocessor directives, and all preprocessor directives are defined using the #.
Also see: C Static Function
Click on the following link to read further: Features of C Language
Syntax
In C, we are provided with a feature called preprocessors, which is used to process the source code written by the programmer before it is compiled. Before the program is passed through a preprocessor, specific instructions, such as directives, are looked for and understood by the preprocessor. These preprocessor directives must begin with a # sign.
The preprocessor is the part of the compiler that executes the essential operations in the given code. Transformations performed by the preprocessors are lexical, which also tells that the preprocessor's output is in the form of text.
In order to define a macro, use the following syntax:
#define macro_name
The above line is passed to the preprocessor, and this assigns a 3.14 value to the PI variable, which can be used for further uses anywhere in the program. If we need to limit the scope f this macro_name within the program itself, we can use the #under to remove the previously declared macro_name for the further assignments.
#undef macro_name
In the above case, macro_name refers to the name of that variable that was defined earlier. # specifies that it’s the preprocessor directive and must be compiled using the preprocessor.