Preprocessor Macros

You can use the #define preprocessor directive to define a macro that assigns a value to an identifier. The preprocessor replaces subsequent occurrences of that identifier with its assigned value until the identifier is undefined with the #undef preprocessor directive, or until the end of the program source is reached, whichever comes first.

There are two basic types of macro definitions that you can use to assign a value to an identifier:

Object-like Macros Replaces a single identifier with a specified token, or constant value.
Function-like Macros Associates a user-defined function and argument list to an identifier. When the preprocessor encounters that identifier in the program source, the defined function is inserted in place of the identifier along with any corresponding arguments.

 



Preprocessor Directives
Preprocessing Operations
Conditional Compilation Directives


#define Preprocessor Directive
#undef Preprocessor Directive
Preprocessor Macro Operators