tech-misc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: alx-0008 - Standardize strtoi(3) and strtou(3) from NetBSD
Alejandro Colomar wrote:
> > >> To address this adoption problem, how about changing these function to
> > >> generic functions (in the sense of <tgmath.h>)? In such a way that
> > >> strtoi (n, &end, base, LONG_MIN, LONG_MAX, &status)
> > >> is known to return a 'long' rather than 'intmax_t', and
> > >> strtoi (n, &end, base, INT_MIN, INT_MAX, &status)
> >
> > That, and especially…
>
> Please propose an implementation of the overload-selectinging macro, and
> clarify how this should work:
>
> n = strto*(s, NULL, 0, SHRT_MIN, UINT_MAX, &status);
Indeed, the "usual arithmetic conversions" (ISO C 23 § 6.3.1.8, § 7.27.(7))
would not work well in this case. Instead, one needs to distinguish strtoi
and strtou:
- For strtoi, the first of the types 'signed char', 'short', 'int', 'long',
'long long', 'intmax_t' that contains both the min and the max value.
- For strtou, the first of the types 'unsigned char', 'unsigned short',
'unsigned int', 'unsigned long', 'unsigned long long', 'uintmax_t' that
contains both the min and the max value.
Bruno
Home |
Main Index |
Thread Index |
Old Index