[Zlib-devel] zlib 1.2.3.4 Winter Solstice Edition
Pedro Alves
alves.ped at gmail.com
Tue Dec 29 10:58:35 EST 2009
Hi all!
My first post here, just joined the list. I joined to see
if I could lend a hand at un-hackifying the Windows CE zlib
port, after Vincent mentioning zlib was close to a new
release over at cegcc-devel at sourceforge.net.
On Tuesday 29 December 2009 14:26:58, Cosmin Truta wrote:
> 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)".
Agreed.
_WIN32_WCE isn't the best predicate there is to check
for CE (this particular case is about a C runtime issue, not
an Win32 API issue, although MSFT's headers don't make much
of a distinction; mingw32ce does have such a distinction, just
like it's big brother MinGW --- mingw vs w32api), but it's
good enough. UNDER_CE would be slightly better, as it would
avoid having to define _WIN32_WCE in CFLAGS.
Vincent, I can help with writing patches, if you're unavailable.
> The fall-back definition of ptrdiff_t at line 156 will then correctly
> match this pattern.
--
Pedro Alves
CodeSourcery
More information about the Zlib-devel
mailing list