Closed
Description
A post to the arduino developers' mailing list suggests a smarter way to do macros for (e.g.) max
using "statement expressions":
#define max(a,b) \
({ typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; })
Adopting this will prevent double-evaluating a
and b
if for some reason they themselves are expressions with side effects.