#include <stdio.h>
#include <stdint.h>typedef struct
{unsigned short msg_type;unsigned short msg_len;//msg body len
}st_msg_h;typedef struct{char audio_name[64];uint64_t time_stamp;//输入的要播放的时间戳绝对时间int dec_ch;}st_msg_start;typedef struct
{st_msg_h msg_h;//消息头union {int msg_speed;//A_SPEEDst_msg_start msg_start;//A_STRAT}msg_body;
}st_audio_msg;int main()
{int a, b, c;printf("long long=%d, uint64_t=%d\n", sizeof(long long), sizeof(uint64_t));a = sizeof(st_msg_h);b = sizeof(st_msg_start);c = sizeof(st_audio_msg);printf("a=%d, b=%d, c=%d\n", a, b, c);return 0;
}
关键是包含头文件: stdint.h
运行结果:
[feng@other #34]$make
gcc -o a a.c
[feng@other #35]$./a
long long=8, uint64_t=8
a=4, b=76, c=80