The size of base data type in Ubuntu-AMD64
2008-04-30 10:30
447 查看
都说64位操作系统中的sizeof(int)应该等于8,即8字节,我特意在我的64位AMD CPU的本本上装了一个64位Ubuntu操作系统,当然不完全是为了测试sizeof(int)。可测试结果让我出乎意料,sizeof(int)=4;sizeof(long)=8;我找了g++编译器的选项,但是没有找到能够将sizeof(int)编译成64位的,-mint64被认作不能识别的命令。虽然-m64可以识别,但我认为编译器已经默认使用了该选项,因为使用与不适用该选项结果都是一样的,至少在程序的输出中都是一样的。
测试代码如下:
#include <iostream>
int main(int argc, char argv[])
{
std::cout<<"sizeof(short) = "<<sizeof(short)<<std::endl;
std::cout<<"sizeof(int) = "<<sizeof(int)<<std::endl;
std::cout<<"sizeof(long) = "<<sizeof(long)<<std::endl;
std::cout<<"sizeof(long long)= "<<sizeof(long long)<<std::endl;
std::cout<<"sizeof(float) = "<<sizeof(float)<<std::endl;
std::cout<<"sizeof(double) = "<<sizeof(double)<<std::endl;
std::cout<<"sizeof(long double)="<<sizeof(long double)<<std::endl;
return 0;
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
查看系统信息如下:
uname -a
Linux fibbery-desktop 2.6.24-16-generic #1 SMP Thu Apr 10 12:47:45 UTC 2008 x86_64 GNU/Linux
运行结果如下:
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 8
sizeof(long long)= 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double)=16
测试代码如下:
#include <iostream>
int main(int argc, char argv[])
{
std::cout<<"sizeof(short) = "<<sizeof(short)<<std::endl;
std::cout<<"sizeof(int) = "<<sizeof(int)<<std::endl;
std::cout<<"sizeof(long) = "<<sizeof(long)<<std::endl;
std::cout<<"sizeof(long long)= "<<sizeof(long long)<<std::endl;
std::cout<<"sizeof(float) = "<<sizeof(float)<<std::endl;
std::cout<<"sizeof(double) = "<<sizeof(double)<<std::endl;
std::cout<<"sizeof(long double)="<<sizeof(long double)<<std::endl;
return 0;
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
查看系统信息如下:
uname -a
Linux fibbery-desktop 2.6.24-16-generic #1 SMP Thu Apr 10 12:47:45 UTC 2008 x86_64 GNU/Linux
运行结果如下:
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 8
sizeof(long long)= 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double)=16
相关文章推荐
- mysql5.7.12/13在安装新实例时报错:InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero
- 海洋工作室——网站建设专家:The version of SQL Server in use does not support datatype datetime2 and the Entity Framework.
- Error: The version of SQL Server in use does not support datatype 'datetime2'
- Error: The version of SQL Server in use does not support datatype 'datetime2
- HOW TO: Change the Owner of a User-Defined Data Type That Is in Use in SQL Server 2000
- EF 6.0 The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. c#中的时间
- InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
- The version of SQL Server in use does not support datatype 'datetime2'.
- The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
- [entity framework ] The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
- ADO.NET Entity Framework: The version of SQL Server in use does not support datatype 'datetime2'
- The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. 错误的原因及解决方案
- ERROR: The version of SQL Server in use does not support datatype 'datetime2'.
- The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[BMS.DataAccess.Models.ServiceTyp
- System.Data - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the r
- Install new version of R-base in Ubuntu
- R12: How to add Microsoft Excel as Type to the Create Template List of Values in BI Publisher (Doc ID 1343225.1)
- Fast ways in R to get the first row of a data frame grouped by an identifier
- How to reduce the size of logging database OR How to purge the old data from Logging Database
- Note of big data dummies:Understanding the role of relational databases in big data