Skip to content

Commit 9980db6

Browse files
committed
RGB565: Fix gcc 12.3 compatibility (no std::bit_cast)
1 parent a0bbf45 commit 9980db6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

util/colors_rgb565.hh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ struct RGB565 {
3232

3333
// Construct from raw u16 RGB565 format
3434
RGB565 operator=(uint16_t raw) {
35+
#if defined(__cpp_lib_bit_cast)
3536
*this = std::bit_cast<RGB565>(raw);
37+
#else
38+
std::memcpy(this, (void *)(&raw), 2);
39+
#endif
3640
return *this;
3741
}
3842

@@ -41,7 +45,11 @@ struct RGB565 {
4145
}
4246

4347
constexpr operator uint16_t() const {
48+
#if defined(__cpp_lib_bit_cast)
4449
return std::bit_cast<uint16_t>(*this);
50+
#else
51+
return raw();
52+
#endif
4553
}
4654

4755
//0..255

0 commit comments

Comments
 (0)