___attribute__ 用法
来源:互联网 发布:chromium浏览器 linux 编辑:程序博客网 时间:2024/05/16 19:16
attribute 用法挺多的,网上资料也挺多,大家可以自己搜搜。
我这里主要讲两个较为有用的
1. attribute((packed)) 让结构体等变得 紧凑
这个作用是最小化,尤其用在结构体里面。
struct temp{ int a; int b; char c;};这个大小不用说: 12个字节但如果struct temp{ int a; int b; char c;}__attribute__((packed));这个大小将会是 : 9 个字节
2.attribute((aligned )) 对齐
struct temp{ int a; int b; char c;};
这个计算下大小: 会是 12;
struct temp{ int a; int b; char c;}__attribute__((aligned(8))) ;这个你计算下,将会得到 16;
解释下: 这个对齐 将超出的,会再倍算。 12 > 8 ,但小于 2 * 8
故而会占用 16个字节
0 0
- ___attribute__ 用法
- 转载___attribute__机制介绍
- 用法
- ,, 用法
- 用法
- 用法
- #用法
- ??用法
- !!用法
- CustDialog用法 SimpleAdapter 用法
- hibernate_Restrictions用法 hibernate_Restrictions用法
- extern用法+assert用法
- getParameterValues用法
- rpm用法
- Log4j用法
- NameSpace用法
- sp_executesql 用法
- ShellExecute用法
- win7下java环境变量的配置
- 【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记23 多MVC模式Demo的实现
- 母版页
- WorkPlanning_4
- jquery validation plugin 使用
- ___attribute__ 用法
- 剑指Offer-->斐波那契数列(三种实现方法)
- 欢迎使用CSDN-markdown编辑器
- CSU 1561-(More) Multiplication
- 【HDU】5208 Where is Bob 【DP】
- C++ 继承
- Preliminary understanding of bagging and boosting
- 电力系统软件应用
- Web 开发中很实用的10个效果【附源码下载】