转载:stm32 数据类型的定义(常用的U8,U16,U32到底代表什么)
2017-05-02 15:53
916 查看
在Keil MDK 开发环境里,比如一个 无符号32位整形数据会有很多种表示方法:
1,unsigned int 32 (C语言标准表达方法)
2,uint32_t ;
3 ,u32;
这三种方式都是在表达同一个意思,可为什么ST的开发人员要搞的这么乱呢? 还有其他好多你可能看起来很陌生 ,很不好理解的表达方式,
如:_IO int32_t 他等同于vs32(这个你同样很陌生),不过他还等同于 volatile int32_t, 还等同于 volatile signed int 32;最后这种表达方式才是C语言的标准表达方式,够乱吧,能把初学者弄的晕头转向。
其实ST 搞这么多花样,无非是想开发人员在写代码时定义数据类型能少写几个符号,然后又因为前后版本升级,为了兼容旧版本(主要是V2.0)才会出现这么多表示方法。不管他怎么换,都是基于标准C来的,看清楚以下几个文件你就OK了:core_cm3.h ;stm32f10x.h; stdint.h; 其中每个文件大概作用如下:
stdint.h 这里放着C语言的标准表达方式
core_cm3.h 文件主要针对动态 静态 变量修饰符做出类型扩展
stm32f10x.h 这个文件主要是为了兼容旧版本吧
1,unsigned int 32 (C语言标准表达方法)
2,uint32_t ;
3 ,u32;
这三种方式都是在表达同一个意思,可为什么ST的开发人员要搞的这么乱呢? 还有其他好多你可能看起来很陌生 ,很不好理解的表达方式,
如:_IO int32_t 他等同于vs32(这个你同样很陌生),不过他还等同于 volatile int32_t, 还等同于 volatile signed int 32;最后这种表达方式才是C语言的标准表达方式,够乱吧,能把初学者弄的晕头转向。
其实ST 搞这么多花样,无非是想开发人员在写代码时定义数据类型能少写几个符号,然后又因为前后版本升级,为了兼容旧版本(主要是V2.0)才会出现这么多表示方法。不管他怎么换,都是基于标准C来的,看清楚以下几个文件你就OK了:core_cm3.h ;stm32f10x.h; stdint.h; 其中每个文件大概作用如下:
stdint.h 这里放着C语言的标准表达方式
//第36行开始 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; typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedef unsigned __int64 uint64_t; typedef signed char int_least8_t; typedef signed short int int_least16_t; typedef signed int int_least32_t; typedef signed __int64 int_least64_t; typedef unsigned char uint_least8_t; typedef unsigned short int uint_least16_t; typedef unsigned int uint_least32_t; typedef unsigned __int64 uint_least64_t; typedef signed int int_fast8_t; typedef signed int int_fast16_t; typedef signed int int_fast32_t; typedef signed __int64 int_fast64_t; typedef unsigned int uint_fast8_t; typedef unsigned int uint_fast16_t; typedef unsigned int uint_fast32_t; typedef unsigned __int64 uint_fast64_t; typedef signed int intptr_t; typedef unsigned int uintptr_t; typedef signed __int64 intmax_t; typedef unsigned __int64 uintmax_t;
core_cm3.h 文件主要针对动态 静态 变量修饰符做出类型扩展
#ifdef __cplusplus #define __I volatile #else #define __I volatile const #endif #define __O volatile #define __IO volatile
stm32f10x.h 这个文件主要是为了兼容旧版本吧
typedef int32_t s32; typedef int16_t s16; typedef int8_t s8; typedef const int32_t sc32; typedef const int16_t sc16; typedef const int8_t sc8; typedef __IO int32_t vs32; typedef __IO int16_t vs16; typedef __IO int8_t vs8; typedef __I int32_t vsc32; typedef __I int16_t vsc16; typedef __I int8_t vsc8; typedef uint32_t u32; typedef uint16_t u16; typedef uint8_t u8; typedef const uint32_t uc32; typedef const uint16_t uc16; typedef const uint8_t uc8; typedef __IO uint32_t vu32; typedef __IO uint16_t vu16; typedef __IO uint8_t vu8; typedef __I uint32_t vuc32; typedef __I uint16_t vuc16; typedef __I uint8_t vuc8;
相关文章推荐
- stm32 数据类型的定义(常用的U8,U16,U32到底代表什么)
- stm32常用数据类型 U8、U16、U32到底代表什么?
- STM32系统头文件之数据类型定义u8 u16哪里来的
- 在Keil MDK 开发环境中,写stm32代码时常用的U8,U16,U32代表的含义说明
- u32、u16、u8 数据类型
- u32、u16、u8 数据类型
- Linux下定义Windows常用数据类型
- typedef(自定义数据类型)与#define(宏定义)用法比较(前者定义指针比define好用)---(转载)
- Linux下定义windows常用数据类型
- 问:java中常用数据类型的拆箱与装箱有什么坑
- Linux下定义Windows常用数据类型
- STM32数据类型定义
- OpeCV中常用基本数据类型的定义分析之二
- 【转载】MySQL的常用命令和增删改查语句和数据类型
- STM32数据类型定义
- 转载:PostgreSQL学习手册(四) 常用数据类型
- 教学思路C#之入门三 定义变量及常用数据类型
- SQL Server 2005 常用数据类型详解【转载】
- Printf函数中%p代表什么数据类型
- Linux下定义Windows常用数据类型