24 lines · plain
1.. title:: clang-tidy - bugprone-macro-parentheses2 3bugprone-macro-parentheses4==========================5 6 7Finds macros that can have unexpected behavior due to missing parentheses.8 9Macros are expanded by the preprocessor as-is. As a result, there can be10unexpected behavior; operators may be evaluated in unexpected order and11unary operators may become binary operators, etc.12 13When the replacement list has an expression, it is recommended to surround14it with parentheses. This ensures that the macro result is evaluated15completely before it is used.16 17It is also recommended to surround macro arguments in the replacement list18with parentheses. This ensures that the argument value is calculated19properly.20 21This check corresponds to the CERT C Coding Standard rule22`PRE20-C. Macro replacement lists should be parenthesized.23<https://wiki.sei.cmu.edu/confluence/display/c/PRE02-C.+Macro+replacement+lists+should+be+parenthesized>`_24