[PATCH 3 of 4] cext: fix warnings when building for py3 on Windows

Matt Harbison mharbison72 at gmail.com
Thu Sep 13 17:44:15 EDT 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1536874340 14400
#      Thu Sep 13 17:32:20 2018 -0400
# Node ID 9fa7b40298e9759ae76b9272a26dda00aa3b9a6e
# Parent  058593637119420b3658ca40088de036450bd8aa
cext: fix warnings when building for py3 on Windows

MSVC++ 14 now has standard int types that don't need to be redefined (I didn't
go back to see when they came along since the build system wants either 2008 or
2015), but doesn't have ssize_t.  The FILE pointer in posixfile is only used on
python2.

diff --git a/mercurial/cext/osutil.c b/mercurial/cext/osutil.c
--- a/mercurial/cext/osutil.c
+++ b/mercurial/cext/osutil.c
@@ -1217,7 +1217,9 @@ static PyObject *posixfile(PyObject *sel
 	char fpmode[4];
 	int fppos = 0;
 	int plus;
+#ifndef IS_PY3K
 	FILE *fp;
+#endif
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, PY23("et|si:posixfile",
 							  "et|yi:posixfile"),
diff --git a/mercurial/compat.h b/mercurial/compat.h
--- a/mercurial/compat.h
+++ b/mercurial/compat.h
@@ -3,6 +3,7 @@
 
 #ifdef _WIN32
 #ifdef _MSC_VER
+#if _MSC_VER < 1900
 /* msvc 6.0 has problems */
 #define inline __inline
 #if defined(_WIN64)
@@ -21,6 +22,18 @@ typedef unsigned short uint16_t;
 typedef unsigned long uint32_t;
 typedef unsigned __int64 uint64_t;
 #else
+/* VC++ 14 */
+#include <stdint.h>
+
+#if defined(_WIN64)
+typedef __int64 ssize_t;
+#else
+typedef int ssize_t;
+#endif
+#endif  /* _MSC_VER < 1900 */
+
+#else
+/* not msvc */
 #include <stdint.h>
 #endif
 #else


More information about the Mercurial-devel mailing list