Dear all,

I need to support both hdf5 and tiff files in the same program, and I observed a conflict in hdf5 and ImageMagick include files on Windows 7, when compiling with VC10 for 32-bit architecture. In this case, H5public.h defines "typedef int ssize_t;" whereas magick-config.h defines "typedef long ssize_t;". Indeed both "int" and "long" are 4-byte variables, but anyway the compiler complaints that there is a type redefinition with the wrong data type. You can observe it even with a stupid "hello world" program, just including the two lines:

#include <hdf5.h>
#include <wand/MagickWand.h>

 A possible patch: I changed in H5public.h the ssize_t definition from

/* Define the ssize_t type if it not is defined */
#if H5_SIZEOF_SSIZE_T==0
/* Undefine this size, we will re-define it in one of the sections below */
#undef H5_SIZEOF_SSIZE_T
#if H5_SIZEOF_SIZE_T==H5_SIZEOF_INT
typedef int ssize_t;
#       define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT
#elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG
typedef long ssize_t;
#       define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG
#elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG_LONG
typedef long long ssize_t;
#       define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG
#else /* Can't find matching type for ssize_t */
#   error "nothing appropriate for ssize_t"
#endif
#endif

to

/* Define the ssize_t type if it not is defined */
#if H5_SIZEOF_SSIZE_T==0
/* Undefine this size, we will re-define it in one of the sections below */
#undef H5_SIZEOF_SSIZE_T
#if H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG_LONG
typedef long long ssize_t;
#       define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG
#elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG
typedef long ssize_t;
#       define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG
#elif H5_SIZEOF_SIZE_T==H5_SIZEOF_INT
typedef int ssize_t;
#       define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT
#else /* Can't find matching type for ssize_t */
#   error "nothing appropriate for ssize_t"
#endif
#endif

(ie just inverting the order from INT - LONG - LONG LONG to LONG LONG - LONG - INT.) In this way ssize_t is of type long and there is no conflict with ImageMagick. And I think there is no real change in HDF5 too, since sizeof(int)==sizeof(long).

 First of all: did anybody ever observe any problem of this kind?
 Second question: are there comments to the patch?

 Regards,
        Andrea


------------------------------------------------------------
Dr. Andrea Parenti                      DESY (FS-EC Group)

mail: [email protected]            Notkestrasse 85
web: http://www.desy.de/~parenti/       D-22607 Hamburg
phone: +49 (0)40 8998 3154              Germany
------------------------------------------------------------

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to