瀏覽代碼

avoid clashing definition of round

only enabled if targeting C or a C++ version older than c++17, as it's
assumed that it works in those cases (Arduino targets c++14)
main
John Robinson 3 年之前
父節點
當前提交
76dab293f7
沒有發現已知的金鑰在資料庫的簽署中
共有 1 個檔案被更改,包括 7 行新增4 行删除
  1. +7
    -4
      teensy4/wiring.h

+ 7
- 4
teensy4/wiring.h 查看文件

@@ -145,20 +145,23 @@ constexpr auto max(A&& a, B&& b) -> decltype(a < b ? std::forward<A>(a) : std::f
#define typeof(a) decltype(a)
#endif

#if !defined(__cplusplus) || __cplusplus < 201703L
#define abs(x) ({ \
typeof(x) _x = (x); \
(_x > 0) ? _x : -_x; \
})
#define round(x) ({ \
typeof(x) _x = (x); \
(_x>=0) ? (long)(_x+0.5) : (long)(_x-0.5); \
})
#endif /* __cplusplus < 201703L */

#define constrain(amt, low, high) ({ \
typeof(amt) _amt = (amt); \
typeof(low) _low = (low); \
typeof(high) _high = (high); \
(_amt < _low) ? _low : ((_amt > _high) ? _high : _amt); \
})
#define round(x) ({ \
typeof(x) _x = (x); \
(_x>=0) ? (long)(_x+0.5) : (long)(_x-0.5); \
})
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ({ \

Loading…
取消
儲存