Skip to content

Commit

Permalink
Fix format error of TIXML_SNPRINTF
Browse files Browse the repository at this point in the history
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<int>(error) to avoid the old-style cast warning.
  • Loading branch information
AlbertHungGarmin committed Mar 19, 2024
1 parent 321ea88 commit 1d658f0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tinyxml2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(error), static_cast<unsigned int>(error), lineNum);

if (format) {
size_t len = strlen(buffer);
Expand Down

0 comments on commit 1d658f0

Please sign in to comment.