Fix for PhantomNode packing in MSVC

Changed bool to uint32_t in bit fields to have 4-byte packings for 32 bits:
"c++ compilers will allocate bit-fields in memory as follows:
several consecutive bit-field members of the same type will
be allocated sequentially. As soon as a new type needs to be allocated,
it will be aligned with the beginning of the next logical memory block."

References:
- https://msdn.microsoft.com/en-us/library/ewwyfdbe.aspx
- http://stackoverflow.com/questions/308364/c-bitfield-packing-with-bools/308383#308383
This commit is contained in:
Michael Krasnyk
2016-04-24 14:06:48 +02:00
parent dac2f93383
commit 4363fd64c4
3 changed files with 6 additions and 24 deletions
+2 -5
View File
@@ -71,13 +71,10 @@ struct SegmentID
BOOST_ASSERT(!enabled || id != SPECIAL_SEGMENTID);
}
NodeID id : 31;
bool enabled : 1;
NodeID id : 31;
std::uint32_t enabled : 1;
};
// bit-fields are broken on Windows
#ifndef _MSC_VER
static_assert(sizeof(SegmentID) == 4, "SegmentID needs to be 4 bytes big");
#endif
#endif /* TYPEDEFS_H */