F
Frederick Gotham
I was pondering over writing a fully-portable version of <limits.h> (e.g.
such things as:
#define UINT_MAX ((unsigned)-1)
, when something occurred to me. Just recently on this newsgroup, I and a few
others posted code which yielded a compile-time constant specifying the
amount of bits which are set in an integer expression; then I thought about
IMAX_BITS, and wondered if this is how IMAX_BITS works? Does it just count
how many bits are set?
Is it possible in C to a write a fully-portable version of <limits.h>? I'll
start off with the easy ones:
#define CHAR_BIT (IMAX_BITS((char unsigned)-1))
#define UCHAR_MAX ((char unsigned)-1 + 0)
#define USHRT_MAX ((short unsigned)-1 + 0)
#define UINT_MAX ((unsigned)-1)
#define ULONG_MAX ((long unsigned)-1)
such things as:
#define UINT_MAX ((unsigned)-1)
, when something occurred to me. Just recently on this newsgroup, I and a few
others posted code which yielded a compile-time constant specifying the
amount of bits which are set in an integer expression; then I thought about
IMAX_BITS, and wondered if this is how IMAX_BITS works? Does it just count
how many bits are set?
Is it possible in C to a write a fully-portable version of <limits.h>? I'll
start off with the easy ones:
#define CHAR_BIT (IMAX_BITS((char unsigned)-1))
#define UCHAR_MAX ((char unsigned)-1 + 0)
#define USHRT_MAX ((short unsigned)-1 + 0)
#define UINT_MAX ((unsigned)-1)
#define ULONG_MAX ((long unsigned)-1)