[Zlib-devel] zlib 1.2.0.1 available for testing

Cosmin Truta cosmin at cs.toronto.edu
Thu Apr 3 00:33:00 EST 2003


Oh, no, noo! :((

Now I noticed that neither
  const char __declspec(dllexport) __stdcall * zlibVersion (void);
nor
  const char * __declspec(dllexport) __stdcall zlibVersion (void);

are working with Microsoft C, but

  const char __declspec(dllexport) * __stdcall zlibVersion (void);
and
  __declspec(dllexport) const char * __stdcall zlibVersion (void);

are.
Which means that we cannot put both in ZEXPORT!

So the alternatives are
(1) Move the __declspec(dllexport) in the ZEXTERN
Then I saw the WinAPI reference states that __declspec(dllexport)
should be at the beginning. It didn't use to be this way years ago,
and this may not work with the old MSC (9.0? pre-9.0?).

(2) Add another Z... macro to be put besides ZEXPORT
This is getting messier and messier, and the code becomes virtually
unmaintainable.

So instead of cluttering the code and taking it beyond any limit of
decent readability, I'd say it's healthier if we do it "by the book",
instead of trying to support a Microsoft product that even Microsoft
stopped supporting. In the extreme case when one is stuck with an
ancient MSC, one can always get MinGW for free.


Note that I reverted the char* function prototypes back to
  ZEXTERN const char * ZEXPORT zlibVersion OF((void));

I adapted Christian's patches, too. Perhaps that makefile.gc is a
mistake, is it right, Christian? It appears to come from the unzip
sources, and it doesn't seem to have anything to do with zlib.

So, Mark, you don't have to apply Christian's patches separately.
They are already included in my update (the newer makefiles, and the
WIN32_LEAN_AND_MEAN thing).

One last thing: I shut down a warning in deflate.c, because of a
signed vs. unsigned comparison in deflate.c:longest_match_fast().

@@ -975,7 +983,7 @@
     if (len < MIN_MATCH) return MIN_MATCH - 1;

     s->match_start = cur_match;
-    return len <= s->lookahead ? len : s->lookahead;
+    return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
 }


Here is the zconf.h update, but you can find the entire archive update
(the reversion back to the old *ZEXPORT prototypes, Christian's updates,
the deflate.c fix), at
  http://www.cs.toronto.edu/~cosmin/pngtech/z_rle/zlib-1.2.0.1-cos2.zip

I tested the entire new update using Borland C, Microsoft C and MinGW
under Win32.

Cosmin


/* If building or using a Windows DLL, compile with -DZLIB_DLL.
 * The calls to ZEXTERN functions will be more efficient this way.
 */
#if defined(_WINDOWS) || defined(WINDOWS) || defined(WIN32)
#  ifdef FAR
#    undef FAR
#  endif
#  include <windows.h>
#  if !defined(WIN32) || (defined(__BORLANDC__) && (__BORLANDC__ < 0x500))
#    if defined(ZLIB_DLL) && defined(ZLIB_INTERNAL)
#      define ZEXPORT   WINAPI _export
#      define ZEXPORTVA FAR _cdecl _export
#    else
#      define ZEXPORT   WINAPI
#      define ZEXPORTVA FAR _cdecl
#    endif
#  else
     /* a fully Win32-compliant compiler */
#    define ZEXPORT   WINAPI
#    define ZEXPORTVA CDECL
#    ifdef ZLIB_DLL
#      ifdef ZLIB_INTERNAL
#        define ZEXTERN extern __declspec(dllexport)
#      else
#        define ZEXTERN extern __declspec(dllimport)
#      endif
#    else
#      define ZEXTERN extern
#    endif
#  endif
#endif

#if defined (__BEOS__)
#  ifdef ZLIB_DLL
#    ifdef ZLIB_INTERNAL
#      define ZEXPORT   __declspec(dllexport)
#      define ZEXPORTVA __declspec(dllexport)
#    else
#      define ZEXPORT   __declspec(dllimport)
#      define ZEXPORTVA __declspec(dllimport)
#    endif
#  endif
#endif

#ifndef ZEXPORT
#  define ZEXPORT
#endif
#ifndef ZEXPORTVA
#  define ZEXPORTVA
#endif
#ifndef ZEXTERN
#  define ZEXTERN extern
#endif





More information about the Zlib-devel mailing list