• 博客访问： 250788
• 博文数量： 55
• 博客积分： 0
• 博客等级： 民兵
• 技术积分： 419
• 用 户 组： 普通用户
• 注册时间： 2014-03-06 20:22

2014年（55）

2014-08-18 13:18:01

1.         unsigned char uint8 = 0;
2.         signed char int8 = 0;
3.         unsigned short uint16 = 0;
4.         signed short int16 = 0;
5.         unsigned int uint32 = 0;
6.         signed int int32 = 0;
7.         float fp32 = 0;
8.         double fp64 = 0;
9.         unsigned long ulong = 0;
10. printf("unsigned char is %d bit\n\r", sizeof(uint8)*8);
11. printf("signed char is %d bit\n\r", sizeof(int8)*8);
12. printf("unsigned short is %d bit\n\r", sizeof(uint16)*8);
13. printf("signed short is %d bit\n\r", sizeof(int16)*8);
14. printf("unsigned int is %d bit\n\r", sizeof(uint32)*8);
15. printf("signed int is %d bit\n\r", sizeof(int32)*8);
16. printf("float fp32 is %d bit\n\r", sizeof(fp32)*8);
17. printf("double fp64 is %d bit\n\r", sizeof(fp64)*8);
18. printf("unsigned long is %d bit\n\r", sizeof(ulong)*8);

1. unsigned char is 8 bit
2. signed char is 8 bit
3. unsigned short is 16 bit
4. signed short is 16 bit
5. unsigned int is 32 bit
6. signed int is 32 bit
7. float fp32 is 32 bit
8. double fp64 is 64 bit
9. unsigned long is 32 bit

（上述结果是在arm-gcc编译得出）

Long  int = int = 32bit   short   int   = 16bit

short   int = int = 16bit   long   int =  32bit

解决可移植性