关于int8_t,uint8_t.....等数据类型的理解

实习中,今天在看公司源码的时候,发现前辈给的代码都是这样的

typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef word_t word16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef dword_t dword32;
typedef int64_t int64;
typedef uint64_t uint64;
typedef uint32 color_t;

typedef time_t time64;
typedef wchar_t char16;//宽字符
typedef char    char8;

 身为小白的我内心是这样的      ???????

查找后得出了结论,其实这些都是已经被typedef过的类型:

typedef signed char int8_t;
typedef unsigned char uint8_t;

typedef int int16_t;
typedef unsigned int uint16_t;

typedef long int32_t;
typedef unsigned long uint32_t;

typedef long long int64_t;
typedef unsigned long long uint64_t;   

  这些包含在inttypes.h头文件,据说这样做的原因是方便移植,比如int8就是8位大小占一字节,int32,,32位大小4字节… 
这样相对应的占位符也就清楚了:

char /unsigned char: %c
int : %d 
unsigned int: %u  
long: %ld; 
unsigned long:%lu
long long: %lld(%l64d)
unsigned long long:%Ilu(%l64u)

 即:

int8_t:%c;
uint8_t:%c;

int16_t: %d;
uint16_t:%u;

int32_t:%ld;
uint32_t:%lu;

int64_t:%lld(%l64d);
uint64_t:%llu(%l64u);

资料:https://blog.csdn.net/eusia/article/details/76401235

转载于:https://www.cnblogs.com/curo0119/p/8891906.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值