File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,13 @@ void optimistic_yield(uint32_t interval_us);
216
216
} // extern "C"
217
217
#endif
218
218
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
220
226
221
227
// from this point onward, we need to configure the c++ environment
222
228
#ifdef __cplusplus
@@ -232,7 +238,6 @@ using std::isinf;
232
238
using std::isnan;
233
239
234
240
// 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?
236
241
using std::abs;
237
242
using std::round;
238
243
You can’t perform that action at this time.
0 commit comments