2019q1 Homework1 (list)
contributed by < TsundereChen
>
Note
Function-like macro
- Function-like macro definition
- An identifier followed by a parameter list in parentheses and the replacement tokens
- Parameters are imbedded in the replacement code
- White space can't separate the identifier
- A comma must separate each parameter
- For portability, shouldn't have more than 31 parameters in a macro
__VA_ARGS__
may appear in the replacement list
- Function-like macro invocation
- An identifier followed by a comma-separated list of args in parentheses
- Number of args should match the number of params in the macro definition, unless parameter list in the definition ends with an ellipsis
- If parameter list ends with an ellipsis, the number of args in the invocation should exceed the number of params in the definition
- Preprocessor handles argument substitution
__VA_ARGS__
is replaced by trailing args if permitted by the macro definition
- Example
static inline
versus function-like macro
static inline
should be as quick as function-like macro
- Since both of them replace the original code
typeof
- typeof can be used with experssion or type
- Experssion
typeof(x[0](1))
- Type
typeof(int *)
TODO
Reference