[Zlib-devel] zlib 1.2.3.4 Winter Solstice Edition
Cosmin Truta
cosmin at cs.toronto.edu
Tue Dec 29 09:26:58 EST 2009
On Tue, Dec 29, 2009 at 1:46 AM, Vincent Torri wrote:
>> _WIN32_WCE must not include stddef.h, but __GNUC__ must include it.
>> In fact, stddef.h is one of the few headers that are guaranteed to
>> come with any installation of gcc, regardless the platform.
>
> you are right.
Thank you, Vincent, but now I want take it back... What if another,
non-gcc-based compiler for WinCE comes along? With this design, we
will for ever play a cat-and-mouse game for every WinCE compiler that
appears and doesn't suck.
Let's take a good look at the line in which <stddef.h> is included
(zutil.h:21), and then, at the line in which ptrdiff_t is defined
(zutil.h:156). They're very fragile, and must go hand in hand
together, otherwise the hack at line 155 doesn't work. That's because
_PTRDIFF_T_DEFINED is defined under Visual C++, and the check will
fail under any other non-VC++-based compiler.
The right way to go is *not* by saying "if not _WIN32_WCE or __GNUC__
or compiler X or compiler Y or..." at line 20.
The right way to go is by saying "if not (_WIN32_WCE and _MSC_VER)".
The fall-back definition of ptrdiff_t at line 156 will then correctly
match this pattern.
Best regards,
Cosmin
More information about the Zlib-devel
mailing list