TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  PRE#003

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.