diff --git a/src/H5.c b/src/H5.c index 63d7aa15a26..839edf76b55 100644 --- a/src/H5.c +++ b/src/H5.c @@ -154,6 +154,9 @@ H5_init_library(void) */ H5_INIT_GLOBAL = true; + /* Make sure we picked a good type for ssize_t if it wasn't present */ + HDcompile_assert(sizeof(size_t) == sizeof(ssize_t)); + #ifdef H5_HAVE_PARALLEL { int mpi_initialized; diff --git a/src/H5private.h b/src/H5private.h index eacf0a70b58..769e6c93d1b 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -371,7 +371,7 @@ * Only needed where ssize_t isn't a thing (e.g., Windows) */ #ifndef SSIZE_MAX -#define SSIZE_MAX ((ssize_t)(((size_t)1 << (8 * sizeof(ssize_t) - 1)) - 1)) +#define SSIZE_MAX SSIZE_T_MAX #endif /* diff --git a/src/H5public.h b/src/H5public.h index 09c46e15f8e..9bde45806c4 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -289,21 +289,11 @@ typedef int htri_t; * * Use of ssize_t should be discouraged in new code. */ -#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 +#if defined(_WIN32) && !defined(__MINGW32__) +#include +typedef SSIZE_T ssize_t; +/* This will have been defined to 0 in configure */ +#define H5_SIZEOF_SSIZE_T H5_SIZEOF_SIZE_T #endif /**