But x++ is postincrement though. That means the value of 'x' is inserted,
and after the expression is evaluated, x is incremented. Right?
If we were going to be semiobscure, wouldn't the correct code be
#define MODINC(x,y) (x = ++x % y)
Btw, to the original guy: this loops 'x' around between 0 and (y-1) --
i.e., if y=5, and x=0, successive "calls" to this #define would do
MODINC(x,y); // x=1
MODINC(x,y); // x=2
MODINC(x,y); // x=3
MODINC(x,y); // x=4
MODINC(x,y); // x=0
MODINC(x,y); // x=1
MODINC(x,y); // x=2
MODINC(x,y); // x=3
...
-- Stevie-OReal programmers use COPY CON PROGRAM.EXE
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/