From 625fbbec1d7261bfc76ba9b299f84414b8ffca01 Mon Sep 17 00:00:00 2001 From: Carter Bray Date: Sun, 31 Jul 2016 17:01:47 -0700 Subject: [PATCH 1/4] Automatically detect architecture based on Visual Studio generator DFHACK_BUILD_ARCH is no longer cached on Windows since it is not possible to build Win32 targets with the Win64 generator or vice versa. No change for GCC builds. --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c2db0902..fbafbf659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,17 @@ add_definitions ( "/D_CRT_NONSTDC_NO_WARNINGS") add_definitions( "/wd4503") endif() -SET(DFHACK_BUILD_ARCH "32" CACHE STRING "Architecture to build ('32' or '64')") +# Automatically detect architecture based on Visual Studio generator +IF(MSVC AND NOT DEFINED DFHACK_BUILD_ARCH) + IF(${CMAKE_GENERATOR} MATCHES "Win64") + SET(DFHACK_BUILD_ARCH "64") + ELSE() + SET(DFHACK_BUILD_ARCH "32") + ENDIF() +ELSE() + SET(DFHACK_BUILD_ARCH "32" CACHE STRING "Architecture to build ('32' or '64')") +ENDIF() + IF("${DFHACK_BUILD_ARCH}" STREQUAL "32") SET(DFHACK_BUILD_32 1) SET(DFHACK_BUILD_64 0) From 3b9d37abe5765934def3ba1726b35dde1d5e0aed Mon Sep 17 00:00:00 2001 From: Carter Bray Date: Sun, 31 Jul 2016 17:01:52 -0700 Subject: [PATCH 2/4] Suppress integer conversion warnings inside protobuf source --- depends/protobuf/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/depends/protobuf/CMakeLists.txt b/depends/protobuf/CMakeLists.txt index 085af746f..5b54c8335 100644 --- a/depends/protobuf/CMakeLists.txt +++ b/depends/protobuf/CMakeLists.txt @@ -202,6 +202,9 @@ LIST(APPEND LIBPROTOBUF_FULL_SRCS ${LIBPROTOBUF_LITE_SRCS}) IF(CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wno-sign-compare") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result") +ELSEIF(MSVC) + # Disable warnings for integer conversion to smaller type + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") ENDIF() INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) From 9da2dcb8a26f7d953ea73a0c0e85ed370f900c8e Mon Sep 17 00:00:00 2001 From: Carter Bray Date: Sun, 31 Jul 2016 17:01:57 -0700 Subject: [PATCH 3/4] Fix raw_vcall on Win64 builds MSVC's call conventions on x64 are the same for normal function calls and member function calls (with the addition of the implicit 'this' parameter). --- plugins/ruby/ruby.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ruby/ruby.cpp b/plugins/ruby/ruby.cpp index adc451a19..127a49b69 100644 --- a/plugins/ruby/ruby.cpp +++ b/plugins/ruby/ruby.cpp @@ -1023,7 +1023,7 @@ static VALUE rb_dfmemory_set_clear(VALUE self, VALUE set) /* call an arbitrary object virtual method */ -#ifdef WIN32 +#if defined(_WIN32) && !defined(_WIN64) __declspec(naked) static int raw_vcall(void *that, void *fptr, unsigned long a0, unsigned long a1, unsigned long a2, unsigned long a3, unsigned long a4, unsigned long a5) { From 44913609c8caad7aa8e8240b75273f7e8dc148de Mon Sep 17 00:00:00 2001 From: Carter Bray Date: Sun, 31 Jul 2016 17:02:02 -0700 Subject: [PATCH 4/4] Fix format string warnings --- library/LuaApi.cpp | 2 +- library/VTableInterpose.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 387ac4d97..df077ccc1 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -2373,7 +2373,7 @@ static int internal_setAddress(lua_State *L) // Print via printerr, so that it is definitely logged to stderr.log. uintptr_t iaddr = addr - Core::getInstance().vinfo->getRebaseDelta(); - fprintf(stderr, "Setting global '%s' to %x (%x)\n", name.c_str(), addr, iaddr); + fprintf(stderr, "Setting global '%s' to %p (%p)\n", name.c_str(), (void*)addr, (void*)iaddr); fflush(stderr); return 1; diff --git a/library/VTableInterpose.cpp b/library/VTableInterpose.cpp index 96cbfff9c..c547800c2 100644 --- a/library/VTableInterpose.cpp +++ b/library/VTableInterpose.cpp @@ -309,7 +309,7 @@ VMethodInterposeLinkBase::VMethodInterposeLinkBase(virtual_identity *host, int v */ fprintf(stderr, "Bad VMethodInterposeLinkBase arguments: %d %p (%s)\n", - vmethod_idx, uintptr_t(interpose_method), name_str); + vmethod_idx, interpose_method, name_str); fflush(stderr); abort(); }