[Spice-devel] [PATCH 8/8] mingw32 build: fix build errors
Gerd Hoffmann
kraxel at redhat.com
Thu Jul 8 02:40:57 PDT 2010
Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
client/common.h | 10 ++++++++++
client/windows/platform_utils.cpp | 4 ++++
client/windows/platform_utils.h | 3 ++-
client/zlib_decoder.h | 4 +++-
common/gdi_canvas.c | 4 ++--
5 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/client/common.h b/client/common.h
index 0a8e082..d4f46f8 100644
--- a/client/common.h
+++ b/client/common.h
@@ -33,6 +33,16 @@
#include <string.h>
#ifdef WIN32
+#ifdef __GNUC__
+#define UNICODE 1
+#define _UNICODE 1
+#define WINVER 0x0501
+#define swprintf_s(_str, _len, _fmt, ...) \
+ swprintf(_str, _fmt, ## __VA_ARGS__)
+#define vsnprintf_s(_str, _len1, _len2, _fmt, _valist) \
+ vsnprintf(_str, _len2, _fmt, _valist)
+#define _ftime_s(_t) _ftime(_t)
+#endif
#include <winsock2.h>
#include <windows.h>
diff --git a/client/windows/platform_utils.cpp b/client/windows/platform_utils.cpp
index 0270959..5586221 100644
--- a/client/windows/platform_utils.cpp
+++ b/client/windows/platform_utils.cpp
@@ -40,7 +40,11 @@ void wstring_vprintf(std::wstring& str, const wchar_t* format, va_list ap)
int buf_size = 256;
for (;;) {
AutoArray<wchar_t> buf(new wchar_t[buf_size]);
+#ifdef __GNUC__
+ int r = vswprintf(buf.get(), format, ap);
+#else
int r = vswprintf(buf.get(), buf_size, format, ap);
+#endif
if (r != -1) {
str = buf.get();
return;
diff --git a/client/windows/platform_utils.h b/client/windows/platform_utils.h
index 49f9d39..2f333f7 100644
--- a/client/windows/platform_utils.h
+++ b/client/windows/platform_utils.h
@@ -21,10 +21,11 @@
#include <winsock.h>
#include <winsock2.h>
#include <ws2tcpip.h>
+#include "utils.h"
#define mb() __asm {lock add [esp], 0}
-template<class T, class FreeRes = FreeObject<T>, T invalid = NULL >
+template<class T, class FreeRes = FreeObject<T>, intptr_t invalid = 0 >
class AutoRes {
public:
AutoRes() : res(invalid) {}
diff --git a/client/zlib_decoder.h b/client/zlib_decoder.h
index 84b6f83..4444040 100644
--- a/client/zlib_decoder.h
+++ b/client/zlib_decoder.h
@@ -22,7 +22,9 @@
#include "common.h"
#include "canvas_base.h"
-#define ZLIB_WINAPI
+#ifndef __GNUC__
+#define ZLIB_WINAPI
+#endif
#include <zlib.h>
diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c
index 9c52002..a35ce41 100644
--- a/common/gdi_canvas.c
+++ b/common/gdi_canvas.c
@@ -16,8 +16,8 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <Windows.h>
-#include <Wingdi.h>
+#include <windows.h>
+#include <wingdi.h>
#include "gdi_canvas.h"
#define GDI_CANVAS
#include "canvas_base.c"
--
1.7.1
More information about the Spice-devel
mailing list