Slamtec/rplidar_sdk

Why packing the struct like this?

kevintsq opened this issue · 0 comments

The struct is packed like this:

#if defined(_WIN32)
#pragma pack(1)
#endif

typedef struct sl_lidar_response_measurement_node_hq_t {
    _u16   angle_z_q14; 
    _u32   dist_mm_q2; 
    _u8    quality;  
    _u8    flag;
} __attribute__((packed)) sl_lidar_response_measurement_node_hq_t;

However, putting _u16 before _u32 may harm performance since _u32 may not be aligned in the address for CPU to retrieve _u32 in one cycle in this case. Why not put _u32 before _u16 for better performance?