rcx

library of miscellaneous bits of C code
git clone git://git.rr3.xyz/rcx
Log | Files | Refs | README | LICENSE

commit 1840ba4a5841ae98ba66dfa7392578ff19a56296
parent 376e44db258446d03fe5dfe9d6facecbf28323c0
Author: robert <robertrussell.72001@gmail.com>
Date:   Fri, 19 Aug 2022 18:48:19 -0700

Add isize typedef

For completeness

Currently, we depend on POSIX in a few places, so maybe it is not worth
the effort to avoid including sys/types.h.

Diffstat:
Minc/cext/def.h | 15++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/inc/cext/def.h b/inc/cext/def.h @@ -63,7 +63,20 @@ typedef intmax_t imax; #define IPTR_MAX INTPTR_MAX typedef intptr_t iptr; -/* typedef ssize_t isize; */ +/* Avoid dependence on POSIX sys/types.h for ssize_t */ +#if SIZE_MAX == UCHAR_MAX +typedef schar isize; +#elif SIZE_MAX == USHORT_MAX +typedef short isize; +#elif SIZE_MAX == UINT_MAX +typedef int isize; +#elif SIZE_MAX == ULONG_MAX +typedef long isize; +#elif SIZE_MAX == ULLONG_MAX +typedef llong isize; +#else /* I don't think this can happen */ +#error "Could not find suitable type for isize" +#endif #define U8_MAX UINT8_MAX #define U8_C UINT8_C