Commit 42bdfb8e authored by Volker Krause's avatar Volker Krause
Browse files

Make structure packing for TimezoneZIndexEntry work with MSVC

MSCV cannot put unsigned integers and enums/booleans into the same bit
field by itself. Work around that by putting all into a single unsigned
integer bit field manually.
parent 9674aa96
Pipeline #40259 failed with stage
in 1 minute and 52 seconds
......@@ -71,7 +71,7 @@ KnowledgeDb::Tz KnowledgeDb::timezoneForCoordinate(float lat, float lon, bool *a
if (ambiguous) {
*ambiguous = (*std::prev(it)).isAmbiguous;
return (*std::prev(it)).tz;
return static_cast<Tz>((*std::prev(it)).tz);
static bool compareOffsetData(const QTimeZone::OffsetData &lhs, const QTimeZone::OffsetData &rhs)
......@@ -36,10 +36,18 @@ struct TimezoneZIndexParams {
// geo coordinate to timezone index entry
// Note: MSVC cannot create bitfields across unsigned integer types and enums/bools (as those are signed there)
// so we need to use a single type for the bitfield and do the conversion manually (and very forcefully)
struct TimezoneZIndexEntry {
inline constexpr TimezoneZIndexEntry(uint32_t _z, Tz _tz, bool _isAmbiguous)
: z(_z)
, tz(uint32_t(_tz))
, isAmbiguous(_isAmbiguous)
uint32_t z: 22;
Tz tz: 9;
bool isAmbiguous: 1;
uint32_t tz: 9;
uint32_t isAmbiguous: 1;
static_assert(sizeof(TimezoneZIndexEntry) == 4, "structure is size-sensitive");
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment