Changed: Use static_assert in nlctassert macro if C++0X is supported by compiler

This commit is contained in:
kervala 2011-05-26 16:14:45 +02:00
parent 28d1e2538b
commit e655b0a777
3 changed files with 11 additions and 3 deletions

View file

@ -583,7 +583,11 @@ template<class T, class U> 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.

View file

@ -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

View file

@ -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);