By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 428,529 Members | 864 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,529 IT Pros & Developers. It's quick & easy.

# Fully-portable version of limits.h

 P: n/a I was pondering over writing a fully-portable version of ? 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) -- Frederick Gotham Sep 18 '06 #1
Share this Question
4 Replies

 P: n/a Frederick Gotham ? I'll start off with the easy ones: #define CHAR_BIT (IMAX_BITS((char unsigned)-1)) That's not conforming. CHAR_BIT must be suitable for use in an #if directive, but constant expressions in #if directives may not contain casts. -- Go not to Usenet for counsel, for they will say both no and yes. Sep 18 '06 #2

 P: n/a Ben Pfaff posted: >#define CHAR_BIT (IMAX_BITS((char unsigned)-1)) That's not conforming. CHAR_BIT must be suitable for use in an #if directive, but constant expressions in #if directives may not contain casts. Damn, hadn't thought of that... -- Frederick Gotham Sep 18 '06 #3

 P: n/a Frederick Gotham wrote: Ben Pfaff posted: >>>#define CHAR_BIT (IMAX_BITS((char unsigned)-1)) That's not conforming. CHAR_BIT must be suitable for use in an#if directive, but constant expressions in #if directives may notcontain casts. Damn, hadn't thought of that... And as if that weren't enough, try writing a fully portable replacement for INT_MIN. Extra credit: CHAR_MIN. -- Eric Sosman es*****@acm-dot-org.invalid Sep 19 '06 #4

 P: n/a Frederick Gotham wrote: I was pondering over writing a fully-portable version of

### This discussion thread is closed

Replies have been disabled for this discussion.