mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
Merge pull request #3859 from fishpepper/minmax
Fix for potential dangerous MIN/MAX/ABS macros?
This commit is contained in:
commit
1374c0deb6
1 changed files with 11 additions and 3 deletions
|
@ -37,9 +37,17 @@
|
|||
|
||||
#define CM_S_TO_KM_H(centimetersPerSecond) (centimetersPerSecond * 36 / 1000)
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define ABS(x) ((x) > 0 ? (x) : -(x))
|
||||
#define MIN(a,b) \
|
||||
__extension__ ({ __typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
_a < _b ? _a : _b; })
|
||||
#define MAX(a,b) \
|
||||
__extension__ ({ __typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
_a > _b ? _a : _b; })
|
||||
#define ABS(x) \
|
||||
__extension__ ({ __typeof__ (x) _x = (x); \
|
||||
_x > 0 ? _x : -_x; })
|
||||
|
||||
#define Q12 (1 << 12)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue