For the original article, see here
Macro, a small piece namedCode. InProgramWhen this name is referenced elsewhere, the compiler will automatically replace it with macro content. There are two types of macros. Their differences are mostly manifested in the Code:Object-likeMacros refer to objects, whileFunction-likeMacro refers to function call.
You can define any valid identifier as a macro, connectedC LanguageCan also be reserved, because the Preprocessor does not know which strings are reserved words. This feature is useful in some scenarios. For example, if you want to block the keyword const, because some old compilers do not support const, you can leave the const keyword define empty. However, there are some exceptions. For example, the keywords "defined" used by the pre-processor and the operators (+,-, *,/, =, and so on) in C ++ cannot be defined as macros.
The following content will cover the content
- Object-like macro
- Function-like macro
- Macro Parameters
- Character-based
- Join
- Variable Parameter macro
- Predefined macros
- Undefined macros and repeated definition macros
- Macro Parameter
- Macro trap