From 24a06f28c6031494a96c718dd19239799a9d6675 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 2 Apr 2023 15:58:55 +0200 Subject: [PATCH] /W4: Fix verbose compiler warnings in 'Debug' build mode Warnings caused by symbol ambiguity. Fixed by removing the duplicate definition in 'platform.h'. --- r5dev/tier0/memalloc.h | 37 +++++++++++++++++++++++++++++++++++++ r5dev/tier0/platform.h | 39 --------------------------------------- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/r5dev/tier0/memalloc.h b/r5dev/tier0/memalloc.h index a23e2e39..14f6f01c 100644 --- a/r5dev/tier0/memalloc.h +++ b/r5dev/tier0/memalloc.h @@ -1,8 +1,45 @@ #ifndef TIER0_MEMALLOC_H #define TIER0_MEMALLOC_H +#if defined(MSVC) && ( defined(_DEBUG) || defined(USE_MEM_DEBUG) ) + +#pragma warning(disable:4290) +#pragma warning(push) +//#include + +// MEM_DEBUG_CLASSNAME is opt-in. +// Note: typeid().name() is not threadsafe, so if the project needs to access it in multiple threads +// simultaneously, it'll need a mutex. + +#define MEM_ALLOC_CREDIT_(tag) ((void)0) // Stubbed for now. + +#if defined(_CPPRTTI) && defined(MEM_DEBUG_CLASSNAME) + +template const char* MemAllocClassName(T* p) +{ + static const char* pszName = typeid(*p).name(); // @TODO: support having debug heap ignore certain allocations, and ignore memory allocated here [5/7/2009 tom] + return pszName; +} + +#define MEM_ALLOC_CREDIT_CLASS() MEM_ALLOC_CREDIT_( MemAllocClassName( this ) ) +#define MEM_ALLOC_CLASSNAME(type) (typeid((type*)(0)).name()) +#else +#define MEM_ALLOC_CREDIT_CLASS() MEM_ALLOC_CREDIT_( __FILE__ ) +#define MEM_ALLOC_CLASSNAME(type) (__FILE__) +#endif + +// MEM_ALLOC_CREDIT_FUNCTION is used when no this pointer is available ( inside 'new' overloads, for example ) +#ifdef _MSC_VER +#define MEM_ALLOC_CREDIT_FUNCTION() MEM_ALLOC_CREDIT_( __FUNCTION__ ) +#else +#define MEM_ALLOC_CREDIT_FUNCTION() (__FILE__) +#endif + +#pragma warning(pop) +#else #define MEM_ALLOC_CREDIT_CLASS() #define MEM_ALLOC_CLASSNAME(type) NULL #define MEM_ALLOC_CREDIT_FUNCTION() +#endif #endif /* TIER0_MEMALLOC_H */ \ No newline at end of file diff --git a/r5dev/tier0/platform.h b/r5dev/tier0/platform.h index ca778c8b..c10f3270 100644 --- a/r5dev/tier0/platform.h +++ b/r5dev/tier0/platform.h @@ -271,45 +271,6 @@ template struct AlignOf_t { AlignOf_t() {} AlignOf_t& operator=(const A template < size_t NUM, class T, int ALIGN > struct AlignedByteArrayExplicit_t {}; template < size_t NUM, class T > struct AlignedByteArray_t : public AlignedByteArrayExplicit_t< NUM, T, VALIGNOF_TEMPLATE_SAFE(T) > {}; - -#if defined(MSVC) && ( defined(_DEBUG) || defined(USE_MEM_DEBUG) ) - -#pragma warning(disable:4290) -#pragma warning(push) -//#include - -// MEM_DEBUG_CLASSNAME is opt-in. -// Note: typeid().name() is not threadsafe, so if the project needs to access it in multiple threads -// simultaneously, it'll need a mutex. -#if defined(_CPPRTTI) && defined(MEM_DEBUG_CLASSNAME) - -template const char* MemAllocClassName(T* p) -{ - static const char* pszName = typeid(*p).name(); // @TODO: support having debug heap ignore certain allocations, and ignore memory allocated here [5/7/2009 tom] - return pszName; -} - -#define MEM_ALLOC_CREDIT_CLASS() MEM_ALLOC_CREDIT_( MemAllocClassName( this ) ) -#define MEM_ALLOC_CLASSNAME(type) (typeid((type*)(0)).name()) -#else -#define MEM_ALLOC_CREDIT_CLASS() MEM_ALLOC_CREDIT_( __FILE__ ) -#define MEM_ALLOC_CLASSNAME(type) (__FILE__) -#endif - -// MEM_ALLOC_CREDIT_FUNCTION is used when no this pointer is available ( inside 'new' overloads, for example ) -#ifdef _MSC_VER -#define MEM_ALLOC_CREDIT_FUNCTION() MEM_ALLOC_CREDIT_( __FUNCTION__ ) -#else -#define MEM_ALLOC_CREDIT_FUNCTION() (__FILE__) -#endif - -#pragma warning(pop) -#else -#define MEM_ALLOC_CREDIT_CLASS() -#define MEM_ALLOC_CLASSNAME(type) NULL -#define MEM_ALLOC_CREDIT_FUNCTION() -#endif - //----------------------------------------------------------------------------- // Macro to assist in asserting constant invariants during compilation