While looking on some legacy code, I found a rather unusual construction (for me at least):
#define loop(i,start,stop) for((i)=(start);(i)<(stop);(i)++)
This macro is then used everywhere instead of regular for loops construction.
I think it's a bad idea in general because it does not really solve a problem nor simplify anything, but can it be dangerous? By dangerous I mean breaking compilation (best case) or (much worse but more interesting) do something else than expected.
The standard cautionary tale against macros is arguments with side effects:
loop(i, x, y++)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With