| 1 |
.. title:: clang-tidy - bugprone-macro-parentheses |
| 2 |
|
| 3 |
bugprone-macro-parentheses |
| 4 |
========================== |
| 5 |
|
| 6 |
|
| 7 |
Finds macros that can have unexpected behavior due to missing parentheses. |
| 8 |
|
| 9 |
Macros are expanded by the preprocessor as-is. As a result, there can be |
| 10 |
unexpected behavior; operators may be evaluated in unexpected order and |
| 11 |
unary operators may become binary operators, etc. |
| 12 |
|
| 13 |
When the replacement list has an expression, it is recommended to surround |
| 14 |
it with parentheses. This ensures that the macro result is evaluated |
| 15 |
completely before it is used. |
| 16 |
|
| 17 |
It is also recommended to surround macro arguments in the replacement list |
| 18 |
with parentheses. This ensures that the argument value is calculated |
| 19 |
properly. |