8000 Fixed warning "unused variable" with GCC 4.4 (issue #912) · tschaban/ArduinoJson@f342dee · GitHub
[go: up one dir, main page]

Skip to content

Commit f342dee

Browse files
committed
Fixed warning "unused variable" with GCC 4.4 (issue bblanchon#912)
1 pa
10000
rent 1d5721f commit f342dee

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ArduinoJson: change log
44
HEAD
55
----
66

7+
* Fixed warning "unused variable" with GCC 4.4 (issue #912)
78
* Added a clear error message for `StaticJsonBuffer` and `DynamicJsonBuffer`
89

910
v6.9.0 (2019-02-26)

src/ArduinoJson/Numbers/FloatTraits.hpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,8 @@ struct FloatTraits<T, 8 /*64bits*/> {
9898
// we use this function to workaround platforms with single precision literals
9999
// (for example, when -fsingle-precision-constant is passed to GCC)
100100
static T forge(uint32_t msb, uint32_t lsb) {
101-
union {
102-
uint64_t integerBits;
103-
T floatBits;
104-
};
105-
integerBits = (uint64_t(msb) << 32) | lsb;
106-
return floatBits;
101+
uint64_t bits = (uint64_t(msb) << 32) | lsb;
102+
return *reinterpret_cast<T*>(&bits);
107103
}
108104
};
109105

@@ -150,12 +146,7 @@ struct FloatTraits<T, 4 /*32bits*/> {
150146
}
151147

152148
static T forge(uint32_t bits) {
153-
union {
154-
uint32_t integerBits;
155-
T floatBits;
156-
};
157-
integerBits = bits;
158-
return floatBits;
149+
return *reinterpret_cast<T*>(&bits);
159150
}
160151

161152
static T nan() {

0 commit comments

Comments
 (0)
0