mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-24 19:20:06 +01:00
Add fallback min/max for compilers that don't have statement expressions
Statement expressions are a GNU C extension and are not available in ISO C. On compilers that don't have them, define these macros as plain conditional expressions, since they are only ever used with expressions that have no side-effects. The statement-expression version is still retained as an added safety measure on GNU-compatible compilers. Signed-off-by: Michael Forney <mforney@mforney.org>
This commit is contained in:
parent
e74ba891f7
commit
06ef34c86b
1 changed files with 5 additions and 0 deletions
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#undef min
|
||||
#undef max
|
||||
#ifdef __GNUC__
|
||||
#define min(a,b) \
|
||||
({ __typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
|
|
@ -44,6 +45,10 @@
|
|||
__typeof__ (b) _b = (b); \
|
||||
_a > _b ? _a : _b; \
|
||||
})
|
||||
#else
|
||||
#define min(a,b) ((a) > (b) ? (b) : (a))
|
||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static inline bool
|
||||
startswith(const char *str, size_t len, const char *prefix, size_t plen)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue