阅读 78

stm32数组首地址,uint8_t范围

简单来说,数据类型uint8_ t/uint 16 _ t/uint 32 _ t/uint 64 _ t只是别名。 具体情况如下:

一、c语言数据基本类型在c语言中有短、int、long、float、double、char六种基本数据类型

1 )整形)短int、int、长int

2 )浮点型: float、double

3 )字符类型: char

二、分析uint8_t _ int _ 16 _ t _ int 32 _ t _ uint 64 _ t1、数据源:这些数据类型都带有_ t。 _t表示这些数据类型由typedef定义,不是新的数据类型。 也就是说,这些其实是我们知道的类型的别名。

2、typedef:typedef用于定义关键字或标识符的别名

3、使用理由:代码维护方便。 例如,c没有bool型。 于是,在一个软件中,一个程序员用int,一个程序员用short会很混乱。 为了定义统一的bool,最好使用一个typedef。 每个程序员都可以使用这个别名的bool。

由于不同的平台具有不同的字长,因此预编译和typedef可以方便地维护代码。

typedef unsigned char uint8_t; uint8_t为别名无符号字符类型4,定义: C99标准定义这些数据类型,具体为: stdint.h

定义类型如下:

typedef signed char int8_t; typedef signed short int int16_t; typedef signed int int32_t; typedef signed __INT64 int64_t;/* exact-widthunsignedintegertypes */typedefunsignedcharuint8_ t; typedefunsignedshortintuint 16 _ t; typedef unsigned int uint32_t; typedef unsigned __INT64 uint64_t;/*7. 18.1.2 */* smallesttypeofatleastnbits *//* minimum-widthsignedintegertypes */typedefsignedcharint _ leded typedef signed int int_least32_t; typedef signed _ int 64 int _ least 64 _ t;/* minimum-widthunsignedintegertypes */typedefunsignedcharuint _ least8_ t; typedefunsignedshortintuint _ least 16 _ t; typedefunsignedintuint _ least 32 _ t; typedef unsigned _ int 64 uint _ least 64 _ t;/*7. 18.1.3 */* fastest minimum-widthsignedintegertypes */typedefsignedint _ fast8_ t; typedef signed int int_fast16_t; typedef signed int int_fast32_t; typedef signed _ int 64 int _ fast 64 _ t;/*快速最小- widthunsignedintegertypes */typedefunsignedintuint _ fast8_ t; typedefunsignedintuint _ fast 16 _ t; typedefunsignedintuint _ fast 32 _ t; typedef unsigned _ int 64 uint _ fast 64 _ t;/*7. 18.1.4 integertypescapableofholdingobjectpointers */# if _ sizeof _ ptr==8typedef signed _ int 64 intptr typter #elsetypedef signed int intptr_t; typedef unsigned int uintptr_t; # endif/*7. 18.1.5 greatest-widthintegertypes */typedef signed _ _ longlong intmax _ t; typedef unsigned _ _ longlonguintmax _ t; 5、格式输出:

1 ) uint16_t %hu

2 ) uint32_t %u

3 ) uint64_t %llu

6、uint8_t型输出:

typedef unsigned char uint8_t; 将uint8_t别名为无符号字符类型uint8_t buf=65; printf('buf=%d ',buf ); //错误printf('buf=%c ',buf ); //正确打印字符的ASCII码


文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐