#define ssize_t long causes error with other library - how to proceed safely?

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
SWSWDCM
Posts: 1
Joined: Mon, 2022-11-07, 18:31

#define ssize_t long causes error with other library - how to proceed safely?

#1 Post by SWSWDCM »

I am using dcmtk 3.6.7 in combination with another library called hdf5. I describe my problem here: https://stackoverflow.com/q/74337792/8735401.

TLDR: because of

Code: Select all

#define ssize_t long
in /include/dcmtk/config/osconfig.h, the following typedef inside hdf5:

Code: Select all

typedef long long ssize_t;
fails.

Thus my question: Is it safe to remove the #define and its surrounding preprocessor logic (see below) or how else should I proceed?

Code: Select all

/* Define `ssize_t' to `long' if <sys/types.h> does not define. */
#define HAVE_NO_TYPEDEF_SSIZE_T
#ifdef HAVE_NO_TYPEDEF_SSIZE_T
#define ssize_t long
#endif

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: #define ssize_t long causes error with other library - how to proceed safely?

#2 Post by Michael Onken »

Hi,

in DCMTK ssize_t is by definition of "long" has least 32 bit while in hdf5 it needs to be at least 64 bit wide (definition "long long"). So my impression is: tha if you only use the typedef from hdf5 I would not see a problem, and there should not be a problem (of course, if you compile on 32 bit platforms, hdf5 might fail then).

Best regards,
Michael

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1435
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: #define ssize_t long causes error with other library - how to proceed safely?

#3 Post by Marco Eichelberg »

I agree. Using an ssize_t typedef with DCMTK that is "too large" is not a problem. DCMTK just expects ssize_t to be available, since on Posix/Linux platforms this is the return type for system functions like read() or write().

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest