I have a huge-ish application that has to run on both AVR and ESP. No problem compiling for AVR, but when compiling for ESP, the below line throws "error: 'abs' cannot be used as a function".
curStepDelay = (100000UL / abs(gaugeTargetPos - gaugeCurPos)) / 1000;
^
I cannot understand why.... Both gaugeTargetPos and gaugeCurPos are declared as ints. AFAICT, abs is defined as:
#define abs(x) ((x)>0?(x):-(x))
VS Intellisense shows abs expands to:
((gaugeTargetPos - gaugeCurPos)>0?(gaugeTargetPos - gaugeCurPos):-(gaugeTargetPos - gaugeCurPos))
That all looks perfectly legit to me. So why the error? Is this just a quirk/bug of this version of the ESP compiler?
This is actually not a problem for me, since this class is not needed on the ESP implementation, but I am curious why this error occurs, just in case it comes up again in the future, since I will be using the ESP a lot for a while.
Regards,
Ray L.