Fix windows compilation with regard to struct/class packing

This commit is contained in:
Surya Suluh 2016-07-06 13:11:56 -04:00
parent b00b15ab98
commit 2091c3443b

View File

@ -46,28 +46,34 @@ namespace extractor
namespace lookup namespace lookup
{ {
// Set to 1 byte alignment // Set to 1 byte alignment
#pragma pack(push, 1)
struct SegmentHeaderBlock struct SegmentHeaderBlock
{ {
std::uint32_t num_osm_nodes; std::uint32_t num_osm_nodes;
OSMNodeID previous_osm_node_id; OSMNodeID previous_osm_node_id;
} __attribute ((packed)); };
#pragma pack(pop)
static_assert(sizeof(SegmentHeaderBlock) == 12, "SegmentHeaderBlock is not packed correctly"); static_assert(sizeof(SegmentHeaderBlock) == 12, "SegmentHeaderBlock is not packed correctly");
#pragma pack(push, 1)
struct SegmentBlock struct SegmentBlock
{ {
OSMNodeID this_osm_node_id; OSMNodeID this_osm_node_id;
double segment_length; double segment_length;
std::int32_t segment_weight; std::int32_t segment_weight;
} __attribute ((packed)); };
#pragma pack(pop)
static_assert(sizeof(SegmentBlock) == 20, "SegmentBlock is not packed correctly"); static_assert(sizeof(SegmentBlock) == 20, "SegmentBlock is not packed correctly");
#pragma pack(push, 1)
struct PenaltyBlock struct PenaltyBlock
{ {
std::uint32_t fixed_penalty; std::uint32_t fixed_penalty;
OSMNodeID from_id; OSMNodeID from_id;
OSMNodeID via_id; OSMNodeID via_id;
OSMNodeID to_id; OSMNodeID to_id;
} __attribute ((packed)); };
#pragma pack(pop)
static_assert(sizeof(PenaltyBlock) == 28, "PenaltyBlock is not packed correctly"); static_assert(sizeof(PenaltyBlock) == 28, "PenaltyBlock is not packed correctly");
} }