uint8_t , uint16_t,uint32_t,uint64_t

来源:互联网 发布:excel数据分行显示 编辑:程序博客网 时间:2024/05/08 08:41

在写套接口时发现uint8_t与uint16_t,不知为什么新的数据类型,便经过一番查询,得:


按照posix标准,一般整形对应的*_t类型为:
1字节     uint8_t
2字节     uint16_t
4字节     uint32_t
8字节     uint64_t

这不是什么新的数据类型,而是经过预编译和typedef进行的一系列别名定义。

下面列出部分C99标准中inttypes.h的内容:

00018 #ifndef __INTTYPES_H_
00019 #define __INTTYPES_H_
00020 
00021 /* Use [u]intN_t if you need exactly N bits.
00022    XXX- doesn't handle the -mint8 option.  */
00023 
00024 typedefsigned char int8_t;
00025 typedefunsigned char uint8_t;
00026 
00027 typedefint int16_t;
00028 typedefunsigned int uint16_t;
00029 
00030 typedeflong int32_t;
00031 typedefunsigned long uint32_t;
00032 
00033 typedeflong long int64_t;
00034 typedefunsigned long long uint64_t;
00035 
00036 typedefint16_t intptr_t;
00037 typedefuint16_t uintptr_t;
00038 
00039 #endif

还有:u_int8_t 和uint8_t,u_int16_t uint16_t......实质是一样的,只不过定义在不同的头文件里而已

1 0
原创粉丝点击