From eeb7ebdcadb2d07c4492a78e7fbe3891c47e1210 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sat, 6 Aug 2016 10:56:21 +0200 Subject: [PATCH] Fix building with MSVC: - no implicit conversion int -> longdouble - bad signature for CTFloat::isSNaN - add missing file to project --- src/complex_t.h | 4 ++-- src/root/ctfloat.d | 9 +++++++++ src/vcbuild/ddmd.visualdproj | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/complex_t.h b/src/complex_t.h index 633001de93..a1ad38890c 100644 --- a/src/complex_t.h +++ b/src/complex_t.h @@ -22,7 +22,7 @@ struct complex_t real_t re; real_t im; - complex_t(real_t re) : re(re), im(0) {} + complex_t(real_t re) : re(re), im(ldouble(0)) {} complex_t(real_t re, real_t im) : re(re), im(im) {} complex_t operator + (complex_t y) { return complex_t(re + y.re, im + y.im); } @@ -54,7 +54,7 @@ struct complex_t int operator != (complex_t y) { return re != y.re || im != y.im; } private: - complex_t() : re(0), im(0) {} + complex_t() : re(ldouble(0)), im(ldouble(0)) {} }; inline complex_t operator * (real_t x, complex_t y) { return complex_t(x) * y; } diff --git a/src/root/ctfloat.d b/src/root/ctfloat.d index 330162c14b..cdeef7e523 100644 --- a/src/root/ctfloat.d +++ b/src/root/ctfloat.d @@ -82,6 +82,15 @@ extern (C++) struct CTFloat return isNaN(r) && !(((cast(ubyte*)&r)[7]) & 0x40); } + // the implementation of longdouble for MSVC is a struct, so mangling + // doesn't match with the C++ header. + // add a wrapper just for isSNaN as this is the only function called from C++ + version(CRuntime_Microsoft) + static bool isSNaN(longdouble ld) + { + return isSNaN(ld.r); + } + static bool isInfinity(real_t r) { return r is real_t.infinity || r is -real_t.infinity; diff --git a/src/vcbuild/ddmd.visualdproj b/src/vcbuild/ddmd.visualdproj index ba5352da12..f96c6ae734 100644 --- a/src/vcbuild/ddmd.visualdproj +++ b/src/vcbuild/ddmd.visualdproj @@ -435,6 +435,9 @@ + + +