yeah, whatever, I have just found another *funny* abuse of macro in a chunk of abnormal working code
this line:
#define DIV(a,b) a / b
WTF is the reason to #define it? and, worse still, why not in a safer way?
#define DIV(a,b) (a) / (b) /* safer version, well ... at least it does what is supposed to do */
2411 lines below, there is this pretty chunk of code:
delta = DIV(x2,x1+2);
and it's of course wrong: with x2=25, and x1=3, it gives the wrong result of 10, and not 5
why? because the preprocessor expands it this way: (25 / 3) + 2
25/(3+2) != (25/3)+2, and the following if { .. } else { .. } is completely fucked up, hence under certain conditions this is the reason for the abnormal working of the firmware I was asked to fix up.
Macros can't be debugged. When you have a macro that translates to a number or a string, the source code will have the macro name, and you can't "see" what the macro translates to. So you don't actually know what is going on. You need disassembly, and/or look at the hw-debugger.
Thus, it hasn't been immediate to realize that macro can confuse people debugging the code, and yet again, I have just messed up three hours of my time for debugging