我是靠谱客的博主 勤劳路灯,这篇文章主要介绍C语言:__packed,现在分享给大家,希望可以做个参考。

 

#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语言内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部