当前位置:网站首页>C language__ attribute__ (packed) attribute (learn)
C language__ attribute__ (packed) attribute (learn)
2022-06-21 18:32:00 【I'm not xiaohaiwa~~~~】
It is the first time to see a structure written like this , I went to Baidu
typedef struct param
{
unsigned char KEY_TYPE;
unsigned char KEY_LEN;
unsigned char KEY_INDEX;
unsigned char Mode;
unsigned char key_data[24];
} __attribute__ ((packed))param;
1. attribute ((packed)) Is used to tell the compiler to cancel the optimized alignment of structures during the compilation process , Align according to the actual number of bytes occupied , yes GCC Special grammar . This function has nothing to do with the operating system , It's about the compiler ,gcc The compiler is not compact , I am here windows Next , use vc The compiler is not compact , use tc The compiler is compact . for example :html
stay TC Next :struct my{ char ch; int a;} sizeof(int)=2;sizeof(my)=3;( Compact mode )windows
stay GCC Next :struct my{ char ch; int a;} sizeof(int)=4;sizeof(my)=8;( Non compact mode ) Array
stay GCC Next :struct my{ char ch; int a;}attrubte ((packed)) sizeof(int)=4;sizeof(my)=5 The Internet
边栏推荐
猜你喜欢

EtherCAT object dictionary analysis

Day11QPainter2021-09-26
![LeetCode 1108 IP地址无效化[暴力] HERODING的LeetCode之路](/img/c6/d3eb6cee92b1c0848bf3d3b58b8b22.png)
LeetCode 1108 IP地址无效化[暴力] HERODING的LeetCode之路

小程序的宿主环境、组件、API、协同工作和发布

EtherCAT igh master station controls three Delta asdaa2 servo rotating circles

2022年高处安装、维护、拆除上岗证题库及模拟考试

存储器分级介绍

带你区分几种并行

启动!阿里巴巴编程之夏2022

Show you how to distinguish several kinds of parallelism
随机推荐
EtherCAT object dictionary analysis
国元期货开户可靠吗?新手如何安全开户?
Compound type of typescript
Typescript的构造方式
Inheritance of typescript
原码、补码、反码的关系
Node modular management
力扣160. 相交链表
C3—Qt实现五子棋小游戏(一)2021.11.07
有了mitmdump还不赶紧扔掉Charles
C语言__attribute__(packed)属性(学习一下)
科普大佬说 | 如何打造自己的AI创造力?
数据库面试总结
markdown写作软件:Ulysses v27
R语言 bug?报错?关于亚变量0、1 结局outcome,outcome变量经过factor和numeric过程,改变了原始内容?
PHP输出函数
EtherCAT igh master station controls three Delta asdaa2 servo rotating circles
2022 high altitude installation, maintenance and removal work license question bank and simulated examination
Structural modeling and Design -- a practical summary of the functions of rotary cutting and fillet chamfering in feature forming of SolidWorks software (drawing a countersunk screw hole)
Typescript的泛型