From a0c8c381aff4d22c2bff1530ae3d8be3631209f5 Mon Sep 17 00:00:00 2001 From: Maksim Smolin Date: Tue, 22 Jan 2019 16:10:18 -0800 Subject: [PATCH 1/4] fix DebuggerBreak warning on Mac debug builds --- public/tier0/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/tier0/platform.h b/public/tier0/platform.h index 64b80a8b..ec0029ef 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -427,7 +427,7 @@ typedef void * HINSTANCE; // On OSX, SIGTRAP doesn't really stop the thread cold when debugging. // So if being debugged, use INT3 which is precise. #ifdef OSX -#define DebuggerBreak() if ( Plat_IsInDebugSession() ) { __asm ( "int $3" ); } else { raise(SIGTRAP); } +#define DebuggerBreak() do { if ( Plat_IsInDebugSession() ) { __asm ( "int $3" ); } else { raise(SIGTRAP); } } while (0) #else #define DebuggerBreak() raise(SIGTRAP) #endif From b6a573013e6280430564f1e74dd8ffce18e4ccf8 Mon Sep 17 00:00:00 2001 From: Maksim Smolin Date: Tue, 22 Jan 2019 17:08:41 -0800 Subject: [PATCH 2/4] fix unused variable in utlblockmemory.h --- public/tier1/utlblockmemory.h | 1 - 1 file changed, 1 deletion(-) diff --git a/public/tier1/utlblockmemory.h b/public/tier1/utlblockmemory.h index 4e5998dc..510d3846 100644 --- a/public/tier1/utlblockmemory.h +++ b/public/tier1/utlblockmemory.h @@ -337,7 +337,6 @@ void CUtlBlockMemory::Purge( int numElements ) } int nBlockSize = NumElementsInBlock(); - int nBlocksOld = m_nBlocks; int nBlocks = ( numElements + nBlockSize - 1 ) / nBlockSize; // If the number of blocks is the same as the allocated number of blocks, we are done. From dba6cca973d0a7335bb1e7c223bfc8dcbc9271ec Mon Sep 17 00:00:00 2001 From: Maksim Smolin Date: Tue, 22 Jan 2019 17:16:30 -0800 Subject: [PATCH 3/4] silence unused typedef warning in COMPILE_TIME_ASSERT --- public/tier0/dbg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/tier0/dbg.h b/public/tier0/dbg.h index 1e9b7225..561992e0 100644 --- a/public/tier0/dbg.h +++ b/public/tier0/dbg.h @@ -567,7 +567,7 @@ public: // of our complicated templates properly. Use some preprocessor trickery // to workaround this #ifdef __GNUC__ - #define COMPILE_TIME_ASSERT( pred ) typedef int UNIQUE_ID[ (pred) ? 1 : -1 ] + #define COMPILE_TIME_ASSERT( pred ) typedef int UNIQUE_ID[ (pred) ? 1 : -1 ] __attribute__((unused)) #else #if _MSC_VER >= 1600 // If available use static_assert instead of weird language tricks. This From 1dccbadb939228007ce808cfbc052c6871e48187 Mon Sep 17 00:00:00 2001 From: Maksim Smolin Date: Tue, 22 Jan 2019 17:20:28 -0800 Subject: [PATCH 4/4] use static_assert in COMPILE_TIME_ASSERT if compiler reports capability through __has_feature --- public/tier0/dbg.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/tier0/dbg.h b/public/tier0/dbg.h index 561992e0..88f880cb 100644 --- a/public/tier0/dbg.h +++ b/public/tier0/dbg.h @@ -566,7 +566,15 @@ public: // We're using an ancient version of GCC that can't quite handle some // of our complicated templates properly. Use some preprocessor trickery // to workaround this -#ifdef __GNUC__ +#ifndef __has_feature + #define __has_feature(x) 0 // Compatibility with non-clang compilers. +#endif +#if __has_feature(cxx_static_assert) + // If available use static_assert instead of weird language tricks. This + // leads to much more readable messages when compile time assert constraints + // are violated. + #define COMPILE_TIME_ASSERT( pred ) static_assert( pred, "Compile time assert constraint is not true: " #pred ) +#elif defined __GNUC__ #define COMPILE_TIME_ASSERT( pred ) typedef int UNIQUE_ID[ (pred) ? 1 : -1 ] __attribute__((unused)) #else #if _MSC_VER >= 1600