[Zlib-devel] zlib 1.2.0.1 available for testing

Dmitriy Anisimkov anisimkov at omsknet.ru
Thu Apr 3 01:53:01 EST 2003


Cosmin Truta wrote:
>>>     /* a fully Win32-compliant compiler */
>>>#    define ZEXPORT   WINAPI
>>>#    define ZEXPORTVA CDECL
>>
>>Cosmin,
>>
>>I still have no source compartibility.
>>The build under Win32 is still WINAPI
>>(for DLL and for static library),
>>
>>But I need to write applications for both Unix and Windows.
>>And I need to use the same calling convention on all platforms.
> 
> You shouldn't worry now. The problem was only in callbacks, and now they
> are clean. If it's not a callback, the calling convention is applied
> transparently, and you don't need to modify your sources. Your Unix
> sources should compile just fine. Or, are you having problems?

Yes, I have. I'm writing not in C, I'm writing in Ada95 programming language,
and I have to declare the exact calling convention for the ZLib functions calls.

Ada95 have no interface to the C preprocessor.
Ada95 has interface only to the already compiled object files.

>>I'm sure for the most portability of the ZLib the calling convention
>>should be the same on all platforms, at least by default.
> 
> When you have a function prototype properly declared in the header, the
> user's code calls it properly, without paying attention to the calling
> convention.

I don't have a headers.
 
>>Ok, if it is not possible, could you give me the some point, where I
>>should put some options in the ./configure or in the make call, for be
>>able to build ZLib with the same CDECL calling convention on all
>>platforms ?
> 
> Try the archive found at
> http://www.cs.toronto.edu/~cosmin/pngtech/z_rle/zlib-1.2.0.1-cos2.zip
> and see if it works. If it doesn't work, let me know why.
> But it should work "out of the box" under Unix, Windows or Cygwin
> (via ./configure)

I did try it, and have a libz.a with a WINAPI calling convention.
I'm using mingw C compiler provided with a GNAT Ada95 compiler.

So, my Ada95 sources should be different for Win32 and for Unix for the current 1.2.0.1 ZLib version.

(Note that ZLib 1.1.4 static library compiled in the mingw
has a most portable CDecl calling convention.
and i had no problems with it.)

I just tried to remove the lines.
--------------------------------------
#  if defined(WIN32) && (!defined(WIN32_LEAN_AND_MEAN))
#    define WIN32_LEAN_AND_MEAN
#  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
---------------------------------------

And the all ZLib routines is good for me.





More information about the Zlib-devel mailing list