From d8c73a8772f88f2323c47ed861617a3bcebbe02f Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 26 May 2011 16:14:45 +0200 Subject: [PATCH] Changed: Use static_assert in nlctassert macro if C++0X is supported by compiler --- code/nel/include/nel/misc/debug.h | 6 +++++- code/nel/include/nel/misc/types_nl.h | 4 ++++ code/ryzom/client/src/interface_v3/ctrl_text_button.cpp | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/code/nel/include/nel/misc/debug.h b/code/nel/include/nel/misc/debug.h index f794e6fca..91f9d9c43 100644 --- a/code/nel/include/nel/misc/debug.h +++ b/code/nel/include/nel/misc/debug.h @@ -583,7 +583,11 @@ template inline T type_cast(U o) /** Compile time assertion */ -#define nlctassert(cond) sizeof(uint[(cond) ? 1 : 0]) +#ifdef NL_ISO_CPP0X_AVAILABLE +# define nlctassert(cond) static_assert(cond, "Compile time assert in "#cond) +#else +# define nlctassert(cond) sizeof(uint[(cond) ? 1 : 0]) +#endif /** * Allow to verify an object was accessed before its destructor call. diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index d0ad3cec7..de86c7659 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -117,6 +117,10 @@ # define NL_COMP_GCC #endif +#if defined(_HAS_CPP0X) || defined(__GXX_EXPERIMENTAL_CXX0X__) +# define NL_ISO_CPP0X_AVAILABLE +#endif + // gcc 3.4 introduced ISO C++ with tough template rules // // NL_ISO_SYNTAX can be used using #if NL_ISO_SYNTAX or #if !NL_ISO_SYNTAX diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 55cae37e3..d2191a4eb 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -113,8 +113,8 @@ bool CCtrlTextButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) _TextureIdOver[2].setTexture((TxName+"_r.tga").c_str()); } - // Compute Bmp Sizes (crash with VC++ 2010) -// nlctassert(NumTexture==3); + // Compute Bmp Sizes + nlctassert(NumTexture==3); rVR.getTextureSizeFromId(_TextureIdNormal[0], _BmpLeftW, _BmpH); rVR.getTextureSizeFromId(_TextureIdNormal[1], _BmpMiddleW, _BmpH); rVR.getTextureSizeFromId(_TextureIdNormal[2], _BmpRightW, _BmpH);