From 1d658f0d954078e0f75b672178c9a82855a4b69e Mon Sep 17 00:00:00 2001 From: Albert Hung Date: Fri, 15 Mar 2024 14:51:11 +0800 Subject: [PATCH] Fix format error of TIXML_SNPRINTF The format "%x" is treated as an unsigned int by the GCC compiler. Use static_cast to cast the error to an unsigned int to match the "%x" type. Additionally, replace int(error) with static_cast(error) to avoid the old-style cast warning. --- tinyxml2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index c5c4870..31a174b 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -2518,7 +2518,8 @@ void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ... char* buffer = new char[BUFFER_SIZE]; TIXMLASSERT(sizeof(error) <= sizeof(int)); - TIXML_SNPRINTF(buffer, BUFFER_SIZE, "Error=%s ErrorID=%d (0x%x) Line number=%d", ErrorIDToName(error), int(error), int(error), lineNum); + TIXML_SNPRINTF(buffer, BUFFER_SIZE, "Error=%s ErrorID=%d (0x%x) Line number=%d", + ErrorIDToName(error), static_cast(error), static_cast(error), lineNum); if (format) { size_t len = strlen(buffer);