c语言小端程序内存对齐
结构体对象和数据类型对象在内存里的布局以及hex值对应关系
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
struct gain_set_s { uint8_t rear_right_rebound; uint8_t rear_right_compress; uint8_t rear_left_rebound; uint8_t rear_left_compress; uint8_t front_right_rebound; uint8_t front_right_compress; uint8_t front_left_rebound; uint8_t front_left_compress; }; typedef struct gain_set_s gain_set_t; gain_set_t set = { .rear_right_rebound = 0xe0, .rear_right_compress = 0xd0, .rear_left_rebound = 0xc0, .rear_left_compress = 0xb0, .front_right_rebound = 0xa0, .front_right_compress = 0x90, .front_left_rebound = 0x80, .front_left_compress = 0x70, }; uint64_t tmp = *(uint64_t*)&set; info("temp set is : %lx", tmp);
log_arrary_desc((uint8_t*)&set, 8, LOG_ARR_BYTE1, "temp set is :");
|