浏览代码

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)
teensy4-core
John Robinson 4 年前
父节点
当前提交
76dab293f7
找不到此签名对应的密钥
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. +7
    -4
      teensy4/wiring.h

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

#define typeof(a) decltype(a) #define typeof(a) decltype(a)
#endif #endif


#if !defined(__cplusplus) || __cplusplus < 201703L
#define abs(x) ({ \ #define abs(x) ({ \
typeof(x) _x = (x); \ typeof(x) _x = (x); \
(_x > 0) ? _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) ({ \ #define constrain(amt, low, high) ({ \
typeof(amt) _amt = (amt); \ typeof(amt) _amt = (amt); \
typeof(low) _low = (low); \ typeof(low) _low = (low); \
typeof(high) _high = (high); \ typeof(high) _high = (high); \
(_amt < _low) ? _low : ((_amt > _high) ? _high : _amt); \ (_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 radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG) #define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ({ \ #define sq(x) ({ \

正在加载...
取消
保存