From bd36129b838dd12535d87479c0337858290c0058 Mon Sep 17 00:00:00 2001 From: lailongwei Date: Tue, 20 Sep 2016 16:51:10 +0800 Subject: [PATCH] fix windows platform compile error --- src/host/http.c | 10 ++++++---- src/host/premake.h | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/host/http.c b/src/host/http.c index 16da3861..e2d89b4d 100644 --- a/src/host/http.c +++ b/src/host/http.c @@ -267,8 +267,9 @@ int http_get(lua_State* L) if (code != CURLE_OK) { - lua_pushnil(L); char errorBuf[1024]; + + lua_pushnil(L); snprintf(errorBuf, sizeof(errorBuf) - 1, "%s\n%s\n", curl_easy_strerror(code), state.errorBuffer); lua_pushstring(L, errorBuf); } @@ -297,10 +298,10 @@ int http_post(lua_State* L) string_init(&state.S); if (curl) { - curl_easy_setopt(curl, CURLOPT_POST, 1); - size_t dataSize; const char* data = luaL_checklstring(L, 2, &dataSize); + + curl_easy_setopt(curl, CURLOPT_POST, 1); if (data && dataSize > 0) { curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)dataSize); @@ -314,8 +315,9 @@ int http_post(lua_State* L) if (code != CURLE_OK) { - lua_pushnil(L); char errorBuf[1024]; + + lua_pushnil(L); snprintf(errorBuf, sizeof(errorBuf) - 1, "%s\n%s\n", curl_easy_strerror(code), state.errorBuffer); lua_pushstring(L, errorBuf); } diff --git a/src/host/premake.h b/src/host/premake.h index a028ad88..d9bb7b33 100644 --- a/src/host/premake.h +++ b/src/host/premake.h @@ -143,6 +143,12 @@ int http_download(lua_State* L); int zip_extract(lua_State* L); #endif +#ifdef _MSC_VER + #ifndef snprintf + #define snprintf _snprintf + #endif +#endif + /* Engine interface */ typedef struct