From: Ivan Maidanski Date: Mon, 4 Jun 2018 07:04:09 +0000 (+0300) Subject: Fix new and delete operators definition for DigitalMars compiler X-Git-Tag: v7.6.8~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=364e6b5f155bb0f87b9a0b7ffa7078acc9785355;p=gc Fix new and delete operators definition for DigitalMars compiler (a cherry-pick of commit 4afeb2fd from 'master') * gc_cpp.cc (new, delete, new[], delete[]): Do not define if __DMC__. * include/gc_cpp.h (new[], delete[], new, delete): Define also if __DMC__. * include/gc_cpp.h [_MSC_VER] (new[], delete[]): Replace _MSC_VER>1020 to defined(GC_OPERATOR_NEW_ARRAY). --- diff --git a/gc_cpp.cc b/gc_cpp.cc index 7d4a2340..1dc11a47 100644 --- a/gc_cpp.cc +++ b/gc_cpp.cc @@ -43,7 +43,7 @@ GC_API void GC_CALL GC_throw_bad_alloc() { GC_ALLOCATOR_THROW_OR_ABORT(); } -#ifndef _MSC_VER +#if !defined(_MSC_VER) && !defined(__DMC__) # if !defined(GC_NEW_DELETE_THROW_NOT_NEEDED) \ && !defined(GC_NEW_DELETE_NEED_THROW) \ diff --git a/include/gc_cpp.h b/include/gc_cpp.h index ede55cda..92ec2317 100644 --- a/include/gc_cpp.h +++ b/include/gc_cpp.h @@ -304,7 +304,7 @@ inline void* operator new(size_t size, GC_NS_QUALIFY(GCPlacement) gcp, GC_NS_QUALIFY(GCCleanUpFunc), void*); #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__DMC__) // The following ensures that the system default operator new[] does not // get undefined, which is what seems to happen on VC++ 6 for some reason // if we define a multi-argument operator new[]. @@ -313,7 +313,7 @@ inline void* operator new(size_t size, GC_NS_QUALIFY(GCPlacement) gcp, // Inlining done to avoid mix up of new and delete operators by VC++ 9 (due // to arbitrary ordering during linking). -# if _MSC_VER > 1020 +# ifdef GC_OPERATOR_NEW_ARRAY inline void* operator new[](size_t size) { void* obj = GC_MALLOC_UNCOLLECTABLE(size); @@ -358,7 +358,7 @@ inline void* operator new(size_t size, GC_NS_QUALIFY(GCPlacement) gcp, } # endif /* !GC_DEBUG */ -# if _MSC_VER > 1020 +# ifdef GC_OPERATOR_NEW_ARRAY // This new operator is used by VC++ 7+ in Debug builds: inline void* operator new[](size_t size, int nBlockUse, const char* szFileName, int nLine)