From 5cb7394301e88e441f66bdbd9a91aa51bc275d33 Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Fri, 22 Feb 2002 22:55:02 +0000 Subject: [PATCH] add NODEFAULT macro for optimizing switch() --- dtool/src/dtoolbase/dtoolbase.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index a27b4cc8a5..ce7e4682d3 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -48,14 +48,27 @@ /* C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data */ #pragma warning (disable : 4244) -/* -#if _MSC_VER < 1300 -#pragma message("VC 6.0") +#if _MSC_VER >= 1300 +#define USING_MSVC7 +//#pragma message("VC 7.0") #else -#pragma message("VC 7.0") +// #pragma message("VC 6.0") #endif -*/ +// Use NODEFAULT to optimize a switch() stmt to tell MSVC to automatically go to the final untested case +// after it has failed all the other cases (i.e. 'assume at least one of the cases is always true') +#ifdef _DEBUG +# define NODEFAULT default: assert(0); +#else +# define NODEFAULT default: __assume(0); // special VC keyword +#endif + +#else /* if !WIN32_VC */ +#ifdef _DEBUG +# define NODEFAULT default: assert(0); +#else +# define NODEFAULT +#endif #endif /* WIN32_VC */ #if defined(USE_UNKNOWN_ALLOCATOR) && !defined(UNKNOWN_ALLOCATOR)