From 50689919b77bdca6311395d8ef0089e5916498d7 Mon Sep 17 00:00:00 2001 From: Peter Matula Date: Tue, 9 Jan 2018 12:52:26 +0100 Subject: [PATCH] rename DEBUG define to TINYXML2_DEBUG The original name is to general. This prevents possible name collisions with other defines, enums, etc. from projects where tinyxml2 is used. --- CMakeLists.txt | 2 +- setversion.py | 2 +- tinyxml2.cpp | 4 ++-- tinyxml2.h | 10 +++++----- tinyxml2/tinyxml2.xcodeproj/project.pbxproj | 2 +- xmltest.cpp | 12 ++++++------ 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f74156d..4f510a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ set(GENERIC_LIB_SOVERSION "6") ################################ # Add definitions -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTINYXML2_DEBUG") ################################ # Add targets diff --git a/setversion.py b/setversion.py index 92b222e..0bf5ad4 100755 --- a/setversion.py +++ b/setversion.py @@ -135,7 +135,7 @@ def cmakeRule2( line ): fileProcess( "CMakeLists.txt", cmakeRule2 ) print( "Release note:" ) -print( '1. Build. g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' ) +print( '1. Build. g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' ) print( '2. Commit. git commit -am"setting the version to ' + versionStr + '"' ) print( '3. Tag. git tag ' + versionStr ) print( ' OR git tag -a ' + versionStr + ' -m [tag message]' ) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 9f3475e..0c903fe 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -2037,7 +2037,7 @@ void XMLDocument::Clear() DeleteNode(_unlinked[0]); // Will remove from _unlinked as part of delete. } -#ifdef DEBUG +#ifdef TINYXML2_DEBUG const bool hadError = Error(); #endif ClearError(); @@ -2052,7 +2052,7 @@ void XMLDocument::Clear() _attributePool.Trace( "attribute" ); #endif -#ifdef DEBUG +#ifdef TINYXML2_DEBUG if ( !hadError ) { TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); diff --git a/tinyxml2.h b/tinyxml2.h index 4cc694b..85cb497 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -47,15 +47,15 @@ distribution. */ /* gcc: - g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe + g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe Formatting, Artistic Style: AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h */ #if defined( _DEBUG ) || defined (__DEBUG__) -# ifndef DEBUG -# define DEBUG +# ifndef TINYXML2_DEBUG +# define TINYXML2_DEBUG # endif #endif @@ -79,7 +79,7 @@ distribution. #endif -#if defined(DEBUG) +#if defined(TINYXML2_DEBUG) # if defined(_MSC_VER) # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } @@ -395,7 +395,7 @@ public: } --_currentAllocs; Item* item = static_cast( mem ); -#ifdef DEBUG +#ifdef TINYXML2_DEBUG memset( item, 0xfe, sizeof( *item ) ); #endif item->next = _root; diff --git a/tinyxml2/tinyxml2.xcodeproj/project.pbxproj b/tinyxml2/tinyxml2.xcodeproj/project.pbxproj index 58c4fcc..c8393bb 100644 --- a/tinyxml2/tinyxml2.xcodeproj/project.pbxproj +++ b/tinyxml2/tinyxml2.xcodeproj/project.pbxproj @@ -137,7 +137,7 @@ buildSettings = { CONFIGURATION_BUILD_DIR = "$(SYMROOT)/Debug"; COPY_PHASE_STRIP = NO; - "GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = DEBUG; + "GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = TINYXML2_DEBUG; ONLY_ACTIVE_ARCH = YES; SYMROOT = build; }; diff --git a/xmltest.cpp b/xmltest.cpp index a647e63..2e27594 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -292,7 +292,7 @@ bool example_4() int main( int argc, const char ** argv ) { - #if defined( _MSC_VER ) && defined( DEBUG ) + #if defined( _MSC_VER ) && defined( TINYXML2_DEBUG ) _CrtMemCheckpoint( &startMemState ); // Enable MS Visual C++ debug heap memory leaks dump on exit _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); @@ -1861,7 +1861,7 @@ int main( int argc, const char ** argv ) } { - // If this doesn't assert in DEBUG, all is well. + // If this doesn't assert in TINYXML2_DEBUG, all is well. tinyxml2::XMLDocument doc; tinyxml2::XMLElement *pRoot = doc.NewElement("Root"); doc.DeleteNode(pRoot); @@ -1876,7 +1876,7 @@ int main( int argc, const char ** argv ) } { - // If this doesn't assert in DEBUG, all is well. + // If this doesn't assert in TINYXML2_DEBUG, all is well. XMLDocument doc; XMLElement* unlinkedRoot = doc.NewElement( "Root" ); XMLElement* linkedRoot = doc.NewElement( "Root" ); @@ -1886,7 +1886,7 @@ int main( int argc, const char ** argv ) } { - // Should not assert in DEBUG + // Should not assert in TINYXML2_DEBUG XMLPrinter printer; } @@ -2266,7 +2266,7 @@ int main( int argc, const char ** argv ) delete[] mem; static const char* note = -#ifdef DEBUG +#ifdef TINYXML2_DEBUG "DEBUG"; #else "Release"; @@ -2280,7 +2280,7 @@ int main( int argc, const char ** argv ) printf("\nParsing dream.xml (%s): %.3f milli-seconds\n", note, duration); } -#if defined( _MSC_VER ) && defined( DEBUG ) +#if defined( _MSC_VER ) && defined( TINYXML2_DEBUG ) { _CrtMemCheckpoint( &endMemState );