Unverified Commit 10a44c83 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Add quasi-sane abs() implementation to Arduino.h (#157)

As mentioned in https://github.com/earlephilhower/arduino-pico/discussions/156#discussion-3376456
parent a55fac8c
......@@ -36,6 +36,18 @@
#include "debug_internal.h"
// Try and make the best of the old Arduino abs() macro. When in C++, use
// the sane std::abs() call, but for C code use their macro since stdlib abs()
// is int but their macro "works" for everything (with potential side effects)
#ifdef abs
#undef abs
#endif // abs
#ifdef __cplusplus
using std::abs;
#else
#define abs(x) ((x)>0?(x):-(x))
#endif
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment