打印
[学习资料]

重新定义一些类型注意

[复制链接]
354|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jf101|  楼主 | 2023-12-18 14:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
重新定义一些类型,防止由于各种平台和编译器的不同,而产生的类型字节数差异,方便移植。
1typedef unsigned char boolean; /* Boolean value type. */
2typedef unsigned long int uint32; /* Unsigned 32 bit value */
3typedef unsigned short uint16; /* Unsigned 16 bit value */
4typedef unsigned char uint8; /* Unsigned 8 bit value */
5typedef signed long int int32; /* Signed 32 bit value */
6typedef signed short int16; /* Signed 16 bit value */
7typedef signed char int8; /* Signed 8 bit value */

不建议使用:

 1typedef unsigned char byte; /* Unsigned 8 bit value type. */
2typedef unsigned short word; /* Unsinged 16 bit value type. */
3typedef unsigned long dword; /* Unsigned 32 bit value type. */
4typedef unsigned char uint1; /* Unsigned 8 bit value type. */
5typedef unsigned short uint2; /* Unsigned 16 bit value type. */
6typedef unsigned long uint4; /* Unsigned 32 bit value type. */
7typedef signed char int1; /* Signed 8 bit value type. */
8typedef signed short int2; /* Signed 16 bit value type. */
9typedef long int int4; /* Signed 32 bit value type. */
10typedef signed long sint31; /* Signed 32 bit value */
11typedef signed short sint15; /* Signed 16 bit value */
12typedef signed char sint7; /* Signed 8 bit value */

使用特权

评论回复
沙发
Bowclad| | 2023-12-19 11:05 | 只看该作者
unsigned char定义为byte有什么不妥吗?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

231

主题

1538

帖子

2

粉丝