The #define directive can be used to assign mnemonic names to constants. There are two forms:
The #define directive substitutes expression for all further found entries of identifier in the source text. The identifier is replaced only if it is a separate token. The identifier is not replaced if it is part of a comment, part of a string, or part of another longer identifier.
The constant identifier is governed by the same rules as variable names. The value can be of any type:
expression can consist of several tokens, such as keywords, constants, constant and non-constant expressions. expression ends with the end of the line and can't be transferred to the next line.
With the parametric form, all the subsequent found entries of identifier will be replaced by expression taking into account the actual parameters. For example:
Be sure to enclose parameters in parentheses when using the parameters in expression, as this will help avoid non-obvious errors that are hard to find. If we rewrite the code without using the brackets, the result will be different:
When using the parametric form, maximum 8 parameters are allowed.
The #undef directive cancels declaration of the macro substitution, defined before.