[Zlib-devel] #elif is not portable on pre-ANSI compilers
Cosmin Truta
cosmin at cs.toronto.edu
Thu Apr 17 02:22:01 EDT 2003
On Wed, 16 Apr 2003, Mark Adler wrote:
> On Wednesday, April 16, 2003, at 12:51 PM, Cosmin Truta wrote:
> > My understanding is that the code works if u4 holds _at_least_ 32
> > bits, and not only if it holds _exactly_ 32 bits.
>
> No, u4 has to be exactly 32 bits. A u4 * pointer is used which must
> increment four bytes at a time.
I can see that now - so we need unsigned short after all.
I wish to add that even the use of 0xff00 should be accompanied by 'U'
(0xff00U), for the sake of 16-bit platforms. Even if the compiled code
is still correct, 0xff00 alone is a negative value that might cause
unnecessary warnings; after all, we are dealing with unsigned values.
Maybe for the sake of consistency, it would be nice to append the 'U'
suffix to each 0xff/0xff00/etc. Plus:
0xedb88320L --> 0xedb88320UL (even if it's only in a comment)
4294967295 --> 0xffffffffUL
crc32.h follows the same pattern.
Cosmin
More information about the Zlib-devel
mailing list