From 4bcbf142a8fd769c6eb48217c2ef077b3e613dab Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 25 Dec 2014 19:05:18 +0300 Subject: [PATCH] Suppress C4127 in asserts --- tinyxml2.cpp | 7 ------- tinyxml2.h | 3 ++- xmltest.cpp | 4 ++++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 7b975c9..5042e8d 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -523,15 +523,8 @@ char* XMLDocument::Identify( char* p, XMLNode** node ) static const int cdataHeaderLen = 9; static const int elementHeaderLen = 1; -#if defined(_MSC_VER) -#pragma warning ( push ) -#pragma warning ( disable : 4127 ) -#endif TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool -#if defined(_MSC_VER) -#pragma warning (pop) -#endif XMLNode* returnNode = 0; if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) { TIXMLASSERT( sizeof( XMLDeclaration ) == _commentPool.ItemSize() ); diff --git a/tinyxml2.h b/tinyxml2.h index 67b3e86..03fd7da 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -77,7 +77,8 @@ distribution. #if defined(DEBUG) # if defined(_MSC_VER) -# define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak() +# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like +# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } //if ( !(x)) WinDebugBreak() # elif defined (ANDROID_NDK) # include # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } diff --git a/xmltest.cpp b/xmltest.cpp index 31e1187..4170977 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -295,6 +295,10 @@ int main( int argc, const char ** argv ) mkdir( "resources/out/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); #endif + { + TIXMLASSERT( true ); + } + if ( argc > 1 ) { XMLDocument* doc = new XMLDocument(); clock_t startTime = clock();