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: v8.0.0~144 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4afeb2fd7678ddb5b5ac5df5fdb08e1cbdb06096;p=gc Fix new and delete operators definition for DigitalMars compiler * 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 73f54cfd..ad361b6e 100644 --- a/gc_cpp.cc +++ b/gc_cpp.cc @@ -29,7 +29,7 @@ built-in "new" and "delete". #include "gc_cpp.h" -#ifndef _MSC_VER +#if !defined(_MSC_VER) && !defined(__DMC__) void* operator new(size_t size) GC_DECL_NEW_THROW { void* obj = GC_MALLOC_UNCOLLECTABLE(size); diff --git a/include/gc_cpp.h b/include/gc_cpp.h index 091e709b..e5f770db 100644 --- a/include/gc_cpp.h +++ b/include/gc_cpp.h @@ -295,7 +295,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[]. @@ -304,7 +304,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) GC_DECL_NEW_THROW { void* obj = GC_MALLOC_UNCOLLECTABLE(size); @@ -351,7 +351,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)