Synopsis: | Be aware of side-effects when using macros |
Language: | C++ |
Severity Level: | 1 |
Category: | Preprocessor |
Description: |
Assume we have the following macro: #define MAX(a, b) ((a) > (b) ? (a) : (b)) When the macro is used as follows: MAX(i++, j) it is expanded as follows: i++ > j ? i++ : j If i is greater than j, it is incremented twice. |