一个int类型到底占多少个字节
2013-11-22 08:26
549 查看
int到底占多少个字节,却跟你的机器环境有关.
[html]
view plaincop
yprint?
1. As youcan see, the typical data type sizes match the ILP32LL model, which is whatmost compilers adhere to on 32-bit platforms. The LP64 model is the de factostandard for compilers that generate code for
64-bit platforms.
As youcan see, the typical data type sizes match the ILP32LL model, which is whatmost compilers adhere to on 32-bit platforms. The LP64 model is the de factostandard for compilers that generate code for 64-bit platforms.
最近在一本有关代码审计的书上看到如上解释.这里很好的解释了int到底应该占多少个字节.
而且从他的角度来看是编译器去适应平台.所以真正决定int占多少字节取决于你的device platforms.
其实无论哪种模型short和char无论哪种model下都保持一致.
我们见得最多的就是ILP32LL模型.这种模型下int和long已经pointer占4个字节 long long占8个字节.
PS:这个表很容易记,中间的数字表明你是64bit还是32bit的机器.前面的I表示int,L表示long,LL表示long
long,P就表示pointer.
位于数字前面的类型表示跟中间的bit数保持一致.举个例子:ILP32LL
就是ILP是32位,LL是64位
[html]
view plaincop
yprint?
1. As youcan see, the typical data type sizes match the ILP32LL model, which is whatmost compilers adhere to on 32-bit platforms. The LP64 model is the de factostandard for compilers that generate code for
64-bit platforms.
As youcan see, the typical data type sizes match the ILP32LL model, which is whatmost compilers adhere to on 32-bit platforms. The LP64 model is the de factostandard for compilers that generate code for 64-bit platforms.
最近在一本有关代码审计的书上看到如上解释.这里很好的解释了int到底应该占多少个字节.
而且从他的角度来看是编译器去适应平台.所以真正决定int占多少字节取决于你的device platforms.
其实无论哪种模型short和char无论哪种model下都保持一致.
我们见得最多的就是ILP32LL模型.这种模型下int和long已经pointer占4个字节 long long占8个字节.
PS:这个表很容易记,中间的数字表明你是64bit还是32bit的机器.前面的I表示int,L表示long,LL表示long
long,P就表示pointer.
位于数字前面的类型表示跟中间的bit数保持一致.举个例子:ILP32LL
就是ILP是32位,LL是64位
相关文章推荐
- Oracle表的常用查询实验(六)
- 维根协议
- c# lambda表达式
- 高老师技术讲座:Android软件开发的整合测试与跨平台策略
- 高老师技术讲座:Android软件开发的整合测试与跨平台策略
- Linux和Unix系统的关系和区别详细介绍
- LeetCode题解: Regular Expression Matching
- Desktop Management Interface & System Management BIOS
- 架构师的第一步:学习两种抽象视角(Abstraction View)
- 从迷宫终点出发——Leo鉴书36
- php数组赋值于js数组,遍历
- ASP.NET MVC 常用内置验证特性 简介
- 如何查看windows的注册表
- 关于文件保存 php
- ENGLISH资料收集(14)-节气
- TCP与UDP的异同(服务端接收数据,客户端发送数据)
- [ASP.NET MVC 小牛之路]16 - Model 验证
- ENGLISH资料收集(13)-健忘
- M2M技术、标准与智慧城市顶层设计方法
- ModelMap和ModelAndView的作用