Skip to content

Commit be7b5a1

Browse files
Fix GCC 4.9.3 Build Errors
Since GCC version 4.9.3 does not support the -Wimplicit-fallthrough warning option or the __attribute__((fallthrough)) annotation, introduce the corresponding fixes to prevent build errors.
1 parent 36ff404 commit be7b5a1

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

tinyxml2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,17 +446,17 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
446446
--output;
447447
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
448448
input >>= 6;
449-
//fall through
449+
TIXML_FALLTHROUGH;
450450
case 3:
451451
--output;
452452
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
453453
input >>= 6;
454-
//fall through
454+
TIXML_FALLTHROUGH;
455455
case 2:
456456
--output;
457457
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
458458
input >>= 6;
459-
//fall through
459+
TIXML_FALLTHROUGH;
460460
case 1:
461461
--output;
462462
*output = static_cast<char>(input | FIRST_BYTE_MARK[*length]);

tinyxml2.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,43 @@ distribution.
9393
#endif
9494
#endif
9595

96+
#ifndef __has_attribute
97+
# define __has_attribute(x) 0
98+
#endif
99+
#ifdef __cplusplus
100+
# ifndef __has_cpp_attribute
101+
# define __has_cpp_attribute(x) 0
102+
# endif
103+
#else
104+
# ifndef __has_c_attribute
105+
# define __has_c_attribute(x) 0
106+
# endif
107+
#endif
108+
109+
#ifdef __cplusplus
110+
# if defined(_MSC_VER)
111+
# define TIXML_FALLTHROUGH (void(0))
112+
# elif (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough))
113+
# define TIXML_FALLTHROUGH [[fallthrough]]
114+
# elif __has_cpp_attribute(clang::fallthrough)
115+
# define TIXML_FALLTHROUGH [[clang::fallthrough]]
116+
# elif __has_attribute(fallthrough)
117+
# define TIXML_FALLTHROUGH __attribute__((fallthrough))
118+
# else
119+
# define TIXML_FALLTHROUGH (void(0))
120+
# endif
121+
#else
122+
# if defined(_MSC_VER)
123+
# define TIXML_FALLTHROUGH (void(0))
124+
# elif __has_c_attribute(fallthrough)
125+
# define TIXML_FALLTHROUGH [[fallthrough]]
126+
# elif __has_attribute(fallthrough)
127+
# define TIXML_FALLTHROUGH __attribute__((fallthrough))
128+
# else
129+
# define TIXML_FALLTHROUGH (void(0))
130+
# endif
131+
#endif
132+
96133
/* Versioning, past 1.0.14:
97134
http://semver.org/
98135
*/

0 commit comments

Comments
 (0)