#include <stdio.h>
#ifndef __packed
#define __packed __attribute__((packed))
#else
#pragma message "Already defined __packed"
#endif
struct node{
int i;
char c;
float f;
char ch;
double d;
} __packed;
int main()
{
printf("sizeof struct node is %dn", sizeof(struct node));
return 0;
}
__packed在linux内核中早有定义:
#ifndef __packed
#define __packed __attribute((packed))
#endif
上面是在文件dump_psb.c中的一小段代码。
最后
以上就是勤劳路灯最近收集整理的关于C语言:__packed的全部内容,更多相关C语言内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复