Skip to content

Commit 1f14878

Browse files
committed
tweak c macros per review
1 parent 0c8c7ab commit 1f14878

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cores/esp8266/Arduino.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ void optimistic_yield(uint32_t interval_us);
219219
// undefine stdlib's definitions when encountered, provide abs that supports floating point for C code
220220
#ifndef __cplusplus
221221
#undef abs
222-
#define abs(x) ((x)>0?(x):-(x))
222+
#define abs(x) ({ __typeof__(x) _x = (x); _x > 0 ? _x : -_x; })
223223
#undef round
224-
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
224+
#define round(x) ({ __typeof__(x) _x = (x); _x >= 0 ? (long)(_x + 0.5) : (long)(_x - 0.5); })
225225
#endif // ifndef __cplusplus
226226

227227
// from this point onward, we need to configure the c++ environment

0 commit comments

Comments
 (0)