Skip to content

Commit ffc3744

Browse files
committed
Restore macros for C code
1 parent 6b36f6e commit ffc3744

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cores/esp8266/Arduino.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,13 @@ void optimistic_yield(uint32_t interval_us);
216216
} // extern "C"
217217
#endif
218218

219-
219+
// undefine stdlib's definitions when encountered, provide abs that supports floating point for C code
220+
#ifndef __cplusplus
221+
#undef abs
222+
#define abs(x) ((x)>0?(x):-(x))
223+
#undef round
224+
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
225+
#endif // ifndef __cplusplus
220226

221227
// from this point onward, we need to configure the c++ environment
222228
#ifdef __cplusplus
@@ -232,7 +238,6 @@ using std::isinf;
232238
using std::isnan;
233239

234240
// Use float-compatible stl abs() and round(), we don't use Arduino macros to avoid issues with the C++ libraries
235-
// TODO: ...does C code need Arduino macros?
236241
using std::abs;
237242
using std::round;
238243

0 commit comments

Comments
 (0)