blueprintmrk / snappy

Automatically exported from code.google.com/p/snappy
Other
0 stars 0 forks source link

Patch for compiling Snappy with MSVC on Windows #83

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When trying to compile Snappy for Windows with MS Visual Studio 12.0, I have 
found a minor glitch.  Below is a patch for this.

--- a/snappy-1.1.1/snappy.h
+++ b/snappy-1.1.1/snappy.h
@@ -44,6 +44,14 @@

 #include "snappy-stubs-public.h"

+// Windows does not define ssize_t by default.  This is a workaround.
+#if defined(_WIN32)
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+
+
 namespace snappy {
   class Source;
   class Sink;

Original issue reported on code.google.com by fal...@gmail.com on 29 Dec 2013 at 9:21

GoogleCodeExporter commented 9 years ago
Sorry but I did not mean a minor glitch, but actually a compiler error.  The 
above patch allows a successful compilation.

Original comment by fal...@gmail.com on 29 Dec 2013 at 9:23

GoogleCodeExporter commented 9 years ago
Hi,

This has been discussed in previous bugs; the short version is that your 
config.h file is expected to supply this macro, not snappy.h. This patch would 
be wrong for MinGW, and in general, we try to avoid too many compiler-specific 
incantations outside config.h, which is where they belong.

Original comment by se...@google.com on 30 Dec 2013 at 11:09

GoogleCodeExporter commented 9 years ago
Ah, I see, sorry.  At any rate, in case anyone else finds this report, the next 
patch works well in both MSVC and MINGW setups:

--- a/snappy-1.1.1/snappy.h
+++ b/snappy-1.1.1/snappy.h
@@ -44,6 +44,14 @@

 #include "snappy-stubs-public.h"

+// Windows does not define ssize_t by default.  This is a workaround.
+#if defined(_WIN32) && !defined(__MINGW32__)
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+
+
 namespace snappy {
   class Source;
   class Sink;

Original comment by fal...@gmail.com on 30 Dec 2013 at 12:25