From 952416c596b776a34a990d35150730c833d27983 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Tue, 11 May 2021 14:06:25 +0100 Subject: [PATCH] Accommodate some changes to 'ssize_t' in VS2019 In more recent versions of MSVC, ssize_t equates to 'long' (for a 32-bit build) or '__int64' (for 64-bit) --- libs/midi++2/mmc.cc | 3 +++ libs/pbd/pbd/msvc_pbd.h | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/midi++2/mmc.cc b/libs/midi++2/mmc.cc index 8a7e175cdd..10fffbe39e 100644 --- a/libs/midi++2/mmc.cc +++ b/libs/midi++2/mmc.cc @@ -32,8 +32,11 @@ #include "midi++/parser.h" #ifndef __INT_MAX__ // 'ssize_t' won't be defined yet + // (except in later versions of MSVC) +#if !defined (_MSC_VER) || (_MSC_VER < 1800) typedef long ssize_t; #endif +#endif using namespace std; using namespace MIDI; diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h index d631e5532c..b4ad77363f 100644 --- a/libs/pbd/pbd/msvc_pbd.h +++ b/libs/pbd/pbd/msvc_pbd.h @@ -154,11 +154,20 @@ typedef int (FAR PBDEXTN_APICALLTYPE *CYGINIT_API)(unsigned int); #ifndef _SSIZE_T_ #define _SSIZE_T_ -typedef long _ssize_t; + +#ifdef SSIZE_T +typedef SSIZE_T _ssize_t; +#elif _MSC_VER < 1800 +typedef long _ssize_t; +#else +#include +typedef LONG_PTR _ssize_t; // AFAICT - LONG_PTR is equivalent to 'long' in Win32 and '__int64' in Win64 !! +#endif #ifndef _NO_OLDNAMES typedef _ssize_t ssize_t; #endif + #endif /* ! _SSIZE_T_ */ typedef unsigned int nfds_t;