From a02d419da731897431c57a2391855fe62a06e3bd Mon Sep 17 00:00:00 2001 From: sdixon Date: Fri, 13 Sep 2024 14:06:57 +0100 Subject: [PATCH] fixing c++ wrapper build for MSVC and also fixing the byte-ordering bug for double data in portablexdrlib for MSVC --- extlib/portablexdr-4.9.1/xdr_float.c | 4 ++-- extlib/portablexdr-4.9.1/xdr_stdio.c | 2 +- source/wrappers/c++/CMakeLists.txt | 2 +- source/wrappers/c++/structdata.hpp | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/extlib/portablexdr-4.9.1/xdr_float.c b/extlib/portablexdr-4.9.1/xdr_float.c index 9dec57ed..fcd9e781 100644 --- a/extlib/portablexdr-4.9.1/xdr_float.c +++ b/extlib/portablexdr-4.9.1/xdr_float.c @@ -232,7 +232,7 @@ xdr_double(xdrs, dp) id.sign = vd.sign; lp = (long *)(void *)&id; #endif -#if defined(__CYGWIN32__) || defined(__MINGW32__) +#if defined(__CYGWIN32__) || defined(__MINGW32__) || defined(_WIN32) return (XDR_PUTLONG(xdrs, lp+1) && XDR_PUTLONG(xdrs, lp)); #else return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); @@ -241,7 +241,7 @@ xdr_double(xdrs, dp) case XDR_DECODE: #if !defined(vax) lp = (long *)dp; -#if defined(__CYGWIN32__) || defined(__MINGW32__) +#if defined(__CYGWIN32__) || defined(__MINGW32__) || defined(_WIN32) return (XDR_GETLONG(xdrs, lp+1) && XDR_GETLONG(xdrs, lp)); #else return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp)); diff --git a/extlib/portablexdr-4.9.1/xdr_stdio.c b/extlib/portablexdr-4.9.1/xdr_stdio.c index 390aea30..194e795d 100644 --- a/extlib/portablexdr-4.9.1/xdr_stdio.c +++ b/extlib/portablexdr-4.9.1/xdr_stdio.c @@ -54,7 +54,7 @@ static char sccsid[] = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro"; #include "byteswap.h" -#if defined(__CYGWIN32__) || defined(__MINGW32__) +#if defined(__CYGWIN32__) || defined(__MINGW32__) || defined(_WIN32) #include #include unsigned int _CRT_fmode = _O_BINARY; diff --git a/source/wrappers/c++/CMakeLists.txt b/source/wrappers/c++/CMakeLists.txt index 90146495..8bf3ebe1 100755 --- a/source/wrappers/c++/CMakeLists.txt +++ b/source/wrappers/c++/CMakeLists.txt @@ -76,7 +76,7 @@ if( WIN32 OR MINGW ) if( MINGW ) set( LINK_LIB ${LINK_LIB} ${XDR_LIBRARIES} ws2_32 dlfcn-win32::dl Iconv::Iconv liblzma::liblzma ZLIB::ZLIB crypt32 stdc++ ) else() - set( LINK_LIB ${LINK_LIB} ${XDR_LIBRARIES} ws2_32 dlfcn-win32::dl ) + set( LINK_LIB ${LINK_LIB} ${XDR_LIBRARIES} ws2_32 crypt32 dlfcn-win32::dl ) endif() elseif( TIRPC_FOUND ) set( LINK_LIB ${LINK_LIB} ${TIRPC_LIBRARIES} ) diff --git a/source/wrappers/c++/structdata.hpp b/source/wrappers/c++/structdata.hpp index 72ec506f..6a3c1019 100755 --- a/source/wrappers/c++/structdata.hpp +++ b/source/wrappers/c++/structdata.hpp @@ -35,6 +35,8 @@ class LIBRARY_API StructData { std::string tname = typeid(T).name(); #ifdef __GNUC__ std::string demangled_name(abi::__cxa_demangle(tname.c_str(), nullptr, nullptr, &status)); +#elif _MSC_VER && !__INTEL_COMPILER + std::string demangled_name = tname; #else char demangled[1024]; UnDecorateSymbolName(tname, demangled, sizeof(demangled), UNDNAME_COMPLETE);