在MDK 开发环境里,比如一个 无符号32位整形数据会有很多种表示方法:
1. unsigned int 32 (C语言标准表达方法)
2. uint32_t ;
3. u32;
这三种方式都是在表达同一个意思,如:_IO int32_t 他等同于vs32,还等同于 volatile int32_t,
**volatile signed int 32 这种表达方式才是C语言的标准表达方式**
一般来说,一个C的工程中一定要做一些这方面的工作,因为你会涉及到跨平台,不同的平台会有不同的字长,所以利用预编译和typedef可以让你最有效的维护你的代码。为了用户的方便,C99标准的C语言硬件为我们定义了这些类型,我们放心使用就可以了。
按照posix标准,一般整形对应的*_t类型为:
1字节 uint8_t
2字节 uint16_t
4字节 uint32_t
8字节 uint64_t
uint8_t,uint16_t,uint32_t等都不是什么新的数据类型,它们只是使用typedef给类型起的别名






1.u8就是unsigned char ,是8位无符号char类型的值
/* exact-width signed integer types */
typedef signed char int8_t; // 标准表达方式 signed char 被等同于 int8_t;
typedef signed short int int16_t;
typedef signed int int32_t; //在32位环境里,int代表4个字节32位!!
typedef signed __INT64 int64_t;
/* exact-width unsigned integer types */
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __INT64 uint64_t;
typedef int32_t s32;
typedef int16_t s16;
typedef int8_t s8;
typedef uint32_t u32; //32位
typedef uint16_t u16; //16位
typedef uint8_t u8; //8位
2.Size_t (1)size_t size_t是C++标准在stddef.h中定义的。这个类型足以用来表示对象的大小。size_t的真实类型与操作系统有关。size_t在32位架构上是4字节,在64位架构上是8字节,在不同架构上进行编译时需要注意这个问题。而int在不同架构下都是4字节,与size_t不同;且int为带符号数,size_t为无符号数。
在32位架构中被普遍定义为: typedef unsigned int size_t; 而在64位架构中被定义为: typedef
unsigned long size_t;
详细解释:https://blog.csdn.net/elen005/article/details/79516136(2)ssize_t
ssize_t是有符号整型,在32位机器上等同与int,在64位机器上等同与long int
在32位架构中被普遍定义为: typedef int size_t; 而在64位架构中被定义为: typedef long
size_t;
(3)size_t和ssize_t作用size_t一般用来表示一种计数,比如有多少东西被拷贝等。例如:sizeof操作符的结果类型是size_t,该类型保证能容纳实现所建立的最大对象的字节大小。
它的意义大致是“适于计量内存中可容纳的数据项目个数的无符号整数类型”。所以,它在数组下标和内存管理函数之类的地方广泛使用。而ssize_t这个数据类型用来表示可以被执行读写操作的数据块的大小.它和size_t类似,但必需是signed.意即:它表示的是signed
size_t类型的。