Subject: Re: win32 buid issue

Re: win32 buid issue

From: Guenter <lists_at_gknw.net>
Date: Tue, 01 Jun 2010 19:48:55 +0200

Hi,
Am 23.05.2010 01:22, schrieb Grubsky Grigory:
> I would like to offer some patches.
>
> 1. VC swears at uint8_t (libssh2_priv.h line 492)
> 8<------------------------------------------------------
> --- 00/libssh2_priv.h 2010-04-30 08:06:04 +0400
> +++ 01/libssh2_priv.h 2010-05-23 03:06:34 +0400
> @@ -41,6 +41,7 @@
> #define LIBSSH2_PRIV_H 1
>
> #ifdef _WIN32
> + typedef unsigned __int8 uint8_t;
> #ifndef _CRT_SECURE_NO_DEPRECATE
> #define _CRT_SECURE_NO_DEPRECATE 1
> #endif /* _CRT_SECURE_NO_DEPRECATE */
> 8<------------------------------------------------------

this is at the wrong place, and to generic. The uint8_t define clashes
with MingW32 headers, and beside that we have already similar defines in
libssh2.h + libssh2_priv.h. I've now tried to clean up this MSVC crap
since its really bad to have these things at three different places.
Here's what I've done ...
removed this MSVC stuff from libssh2_priv.h since clashes with MingW32
and wrong place:
diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h
index ba0f883..fd570e4 100644
--- a/src/libssh2_priv.h
+++ b/src/libssh2_priv.h
@@ -40,13 +40,6 @@
  #ifndef LIBSSH2_PRIV_H
  #define LIBSSH2_PRIV_H 1

-#ifdef _MSC_VER
- typedef unsigned __int8 uint8_t;
- #ifndef _CRT_SECURE_NO_DEPRECATE
- #define _CRT_SECURE_NO_DEPRECATE 1
- #endif /* _CRT_SECURE_NO_DEPRECATE */
-#endif /* _MSC_VER */
-
  #define LIBSSH2_LIBRARY
  #include "libssh2_config.h"

added the _CRT_SECURE_NO_DEPRECATE define to libssh2_config.h;
removed the ssize_t and uint32_t defines:
diff --git a/win32/libssh2_config.h b/win32/libssh2_config.h
index 4fce0e3..2e5c5d1 100644
--- a/win32/libssh2_config.h
+++ b/win32/libssh2_config.h
@@ -19,12 +19,12 @@
  #define HAVE_SELECT

  #ifdef _MSC_VER
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif /* _CRT_SECURE_NO_DEPRECATE */
  #define snprintf _snprintf
  #if _MSC_VER < 1500
  #define vsnprintf _vsnprintf
-#else
-#define ssize_t SSIZE_T
-#define uint32_t UINT32
  #endif
  #define strncasecmp _strnicmp
  #define strcasecmp _stricmp
@@ -41,4 +41,3 @@

  #endif /* LIBSSH2_CONFIG_H */

changed the MSVC-specific ifdef block so that we have a common one for
all MSVC compilers + the previous _MSC_VER <= 1400 case - however I'm
not sure if we need this at all because the only thing which remains
then is the difference of using __int64 vs. long long -- though I doubt
that __int64 really vanished from the PSDK headers with MSC_VER >= 1400
(someone who is on latest MSVC please check if there's still a __int64
type);
from the above removal of size_t and uint32_t defines its clear that
even _MSC_VER >= 1500 has lack of these types, so I just assume that
1400 lacks too, and thus typedef'd these for all MSVC, and uint8_t is
anyway newly added and was even only ifdef'd with _WIN32, so this all
leads to this hunk:

diff --git a/include/libssh2.h b/include/libssh2.h
index 93574e1..432588b 100644
--- a/include/libssh2.h
+++ b/include/libssh2.h
@@ -73,13 +73,16 @@ typedef unsigned char uint8_t;
  typedef unsigned int uint32_t;
  #endif

-#if defined(LIBSSH2_WIN32) && defined(_MSC_VER) && (_MSC_VER <= 1400)
-typedef unsigned __int64 libssh2_uint64_t;
-typedef __int64 libssh2_int64_t;
+#if defined(LIBSSH2_WIN32) && defined(_MSC_VER)
+typedef unsigned char uint8_t;
  typedef unsigned int uint32_t;
-#ifndef _SSIZE_T_DEFINED
+# ifndef _SSIZE_T_DEFINED
  typedef int ssize_t;
-#define _SSIZE_T_DEFINED
+# define _SSIZE_T_DEFINED
+# if (_MSC_VER <= 1400)
+typedef unsigned __int64 libssh2_uint64_t;
+typedef __int64 libssh2_int64_t;
+# endif
  #endif
  #else
  typedef unsigned long long libssh2_uint64_t;

comments? any folks who use MSVC please check recent git, or next snap.

thanks, GŁn.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-06-01