c语言中u8,u16,u32和int区别

c语言中u8,u16,u32和int区别,第1张

这几种方式都是在表达同1个意思,没有区别。

typedef unsigned              char       uint8_t

typedef unsigned short     int         uint16_t

typedef unsigned              int         uint32_t

typedef unsigned          __int64     uint64_t

代码示例

voidTIM3_Int_Init(u16arr,u16psc)

{

//dosomething...

}

扩展资料

u8,u16,u32的使用

示例:

#defineU32  unsignedint

#defineU16  unsignedshort

#defineS32  int

#defineS16  shortint

#defineU8  unsignedchar

#defineS8  char

unsignedchar=u8

unsignedshortint=u16

unsignedlongint=u32

u8是unsigned char,u16是unsigned short。

u8,u16是C语言数据类型,分别代表8位,16位一个字节是8位,所以u8是1个字节,u16是2个字节。

例如:

void TIM3_Int_Init(u16 arr,u16 psc)

{  

//do something...

}

扩展资料:

注意事项

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

stm32f10x.h 这个文件主要是为了兼容旧版本

typedef   uint32_t   u32///32位

typedef   uint16_t   u16///16位

typedef   uint8_t     u8///8位

STM32里的类型定义,见如下说明:

/* Exported types ------------------------------------------------------------*/

typedef signed long s32

typedef signed short s16

typedef signed char s8

typedef signed long const sc32 /* Read Only */

typedef signed short const sc16 /* Read Only */

typedef signed char const sc8 /* Read Only */

typedef volatile signed long vs32

typedef volatile signed short vs16

typedef volatile signed char vs8

typedef volatile signed long const vsc32 /* Read Only */

typedef volatile signed short const vsc16 /* Read Only */

typedef volatile signed char const vsc8 /* Read Only */

typedef unsigned long u32

typedef unsigned short u16

typedef unsigned char u8

typedef unsigned long const uc32 /* Read Only */

typedef unsigned short const uc16 /* Read Only */

typedef unsigned char const uc8 /* Read Only */

typedef volatile unsigned long vu32

typedef volatile unsigned short vu16

typedef volatile unsigned char vu8

typedef volatile unsigned long const vuc32 /* Read Only */

typedef volatile unsigned short const vuc16 /* Read Only */

typedef volatile unsigned char const vuc8 /* Read Only */

Exported_types

<Stm32f10x>

类型定义

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

所以,前面三者依次与后者等价,即:

typedef uint32_t u32

typedef uint16_t u16

typedef uint8_t u8

所述。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/9015199.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-24
下一篇2023-04-24

发表评论

登录后才能评论

评论列表(0条)

    保存