AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.09.14 11:06 "[Tiff] Calltype support", by Martin Schramm
2004.09.15 13:46 "Re: [Tiff] Calltype support", by Frank Warmerdam
2004.09.15 15:02 "Re: [Tiff] Calltype support", by Bob Friesenhahn
2004.09.15 15:25 "Re: [Tiff] Calltype support", by Frank Warmerdam
2004.09.15 15:38 "Re: [Tiff] Calltype support", by Bob Friesenhahn
2004.09.16 17:54 "[Tiff] versioned symbols [Was: Calltype support]", by Jay Berkenbilt
2004.09.16 18:08 "Re: [Tiff] versioned symbols [Was: Calltype support]", by Thomas J. Kacvinsky
2004.09.16 18:22 "Re: [Tiff] versioned symbols [Was: Calltype support]", by Jay Berkenbilt
2004.09.16 18:27 "Re: [Tiff] versioned symbols [Was: Calltype support]", by Thomas J. Kacvinsky
2004.09.16 21:36 "Re: [Tiff] versioned symbols [Was: Calltype support]", by Andrey Kiselev
2004.09.16 22:36 "Re: [Tiff] versioned symbols [Was: Calltype support]", by Bob Friesenhahn
2004.09.19 15:52 "Re: [Tiff] versioned symbols [Was: Calltype support]", by Jay Berkenbilt
2004.09.19 19:34 "Re: [Tiff] versioned symbols [Was: Calltype support]", by Andrey Kiselev

2004.09.14 11:06 "[Tiff] Calltype support", by Martin Schramm

Hello,

we use the LibTiff in a WinNT environment and compile it with calltype __cdecl.

To do this we added a file "tiff_decl.h" with code taken from the JPEGlib routines:

   #ifndef _TIFFDECL_
   #define _TIFFDECL_

   // remove comments to get __cdecl calltype
   // #if defined(_Windows) || defined (_WIN32)
   // #define  _CALLTYPE_  __cdecl
   // #else
   #define  _CALLTYPE_
   // #endif

   #define  STATIC(type)  static type _CALLTYPE_
   #define  EXTERN(type)  extern type _CALLTYPE_
   #define  GLOBAL(type)         type _CALLTYPE_

   #endif  /* _TIFFDECL_ */

This file is includes in tiffio.h and fax3sm_winnt.c

Now in each file we change all function declarations (use monospace font to view):

   BEFORE:                          AFTER:
   -----------------------          -------------------

   int                              GLOBAL(int)
   fname(...)                       fname(...)

   void                             GLOBAL(void)
   fname(...)                       fname(...)

   static int                       STATIC(int)
   fname(...)                       fname(...)

   extern int                       EXTERN(int)
   fname(...)                       fname(...)

   struct XYZ {                     struct XYZ {

     ...                              ...
     void (*fname)(...)               void (_CALLTYPE_ *fname)(...)
     ...                              ...

   }                                }

   typedef void (*fname)           typedef void (_CALLTYPE_ *fname)

           (...)                           (...)

This works perfectly, but has a great disadvantage: Migrating to a new version of the LibTiff is painful because we have to do the same work again.

Have you ever thought about adding calltype support, like the JPEGlib does? I think the readability of the code does not decrease. Or are there other (better?) ways to add calltype support?

Thanks for your help,

Martin Schramm