On Wed, Dec 29, 2010 at 10:20 PM, Daniel Stenberg <[email protected]> wrote:
> On Wed, 29 Dec 2010, Pierre Joye wrote:
>
>> I would say SSIZE_T, always on Windows. Both int or __int64 can be wrong.
>
> I don't disagree that SSIZE_T might be the right answer, but I do have two
> questions about that:
>
> A) what header(s) would we need to include to be sure SSIZE_T is typedef'ed
> and will those headers be the same on all known Windows compilers?
BaseTsd.h, patch attached. Mingw should have it too or should have
size_t already defined in sys/types.h, at least any decent version
(after 2008 or so). Some versions of mingw may define it as int, which
is not really a good idea as far as I can tell.
btw, unless I'm mistaken, mingw does not support x644. I won't go down
the way of the alternative mingw posted by Vincent, enough pains
already :)
> B) in which case is both int and __int64 wrong for ssize_t ?
All, there are no guaranties that ssize_t is an integer (or long for
what matters), same for size_t.
Cheers,
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
diff --git a/include/libssh2.h b/include/libssh2.h
index e011d49..5c33d86 100644
--- a/include/libssh2.h
+++ b/include/libssh2.h
@@ -87,6 +87,10 @@
#ifdef __cplusplus
extern "C" {
#endif
+#ifdef _MSC_VER
+# include <BaseTsd.h>
+# include <WinSock2.h>
+#endif
#include <stddef.h>
#include <string.h>
@@ -121,9 +125,8 @@ typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 libssh2_uint64_t;
typedef __int64 libssh2_int64_t;
-# ifndef _SSIZE_T_DEFINED
-typedef int ssize_t;
-# define _SSIZE_T_DEFINED
+#ifndef ssize_t
+typedef SSIZE_T ssize_t;
#endif
#else
typedef unsigned long long libssh2_uint64_t;
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html