mirror of
https://https.git.savannah.gnu.org/git/tar.git
synced 2026-01-26 16:09:29 +00:00
Port intmax macro to strict C11
Needed for Apple clang version 14.0.0 (clang-1400.0.29.202). * src/common.h (intmax): Define macro only if _Generic works, and use _Generic in it rather that using EXPR_SIGNED. This is needed to make the first argument of verify_expr an integer constant expression, which is required for strict C11. Although GCC is smart enough to treat (1 ? 0 : V) as an integer constant expression even if V is an integer variable, C11 does not require support for this sort of thing.
This commit is contained in:
parent
4e548d150c
commit
0521528cdf
10
src/common.h
10
src/common.h
@ -683,7 +683,15 @@ intmax (intmax_t n)
|
||||
}
|
||||
/* intmax should be used only with signed types.
|
||||
To bypass this check parenthesize the function, e.g., (intmax) (n). */
|
||||
#define intmax(n) verify_expr (EXPR_SIGNED (n), (intmax) (n))
|
||||
#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
|
||||
# define intmax(n) \
|
||||
verify_expr (_Generic (n, \
|
||||
unsigned char: 0, unsigned short int: 0, \
|
||||
unsigned int: 0, unsigned long int: 0, \
|
||||
unsigned long long int: 0, \
|
||||
default: 1), \
|
||||
(intmax) (n))
|
||||
#endif
|
||||
|
||||
/* Represent N using a signed integer I such that (uintmax_t) I == N.
|
||||
With a good optimizing compiler, this is equivalent to (intmax_t) i
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user