A Subtle Sin Of Macro Expansion

It has been said ad nauseam that macros ought to be avoided, usually with good reason. But it was only through the pain and suffering (which is an unfortunate prerequisite of internalized good practice) that I have come to believe the following truism:

No argument of a function-like preprocessor macro should ever modify state.

It is essential either to follow this principal, or to remember that in macro expansion, the expressions used as arguments will be copied first, and evaluated last. If a macro uses the same argument twice, and the argument includes a state change (eg. x++ or perhaps another macro), then the state change will be evaluated twice.