STM32-the difference in data types in MDK4 and MDK5

  • First, let's look at the definition of data types in MD4:

  • Then we jump to its definition to view its definition:
typedef unsigned long  u32;

typedef unsigned short u16;

typedef unsigned char  u8;

/*首先我们来认识typedef,这是用来为复杂的声明定义简单的别名,也就是说,我们可以用它来给我们的数据类型来进行定义。*/

/* 然后我们再来看之后的unsigned,unsigned用于限定后面的为无符号类型,如果后面不加什么的话,就默认为unsigned int。*/

/*unsigned long 无符号长数据  unsigned char 无符号字符型 unsigned short无符号短数据*/ 

/*u8,u16,u32都是C语言数据类型,分别代表8位,16位,32位长度的数据类型,一个字节是8位。*/

/*所以u8是1个字节,u16是2个字节,u32是4个字节。*/
  • In MDK5, we can see that its definition of data types is roughly the same as MDK4.
typedef unsigned          char uint8_t;

typedef unsigned short     int uint16_t;

typedef unsigned           int uint32_t;

typedef unsigned       __INT64 uint64_t;


By comparing with the above, we can know that in MDK5, the definition of some data types in MDK has been slightly changed. For example, u8 is used in MDK4 and uint8_t is used in MDK5. This is to make the program more unified and standardized. The "t" behind it should be used to identify the data type defined by typedef, so that the rest of the developers will know it, so that it will not be confused.

Guess you like

Origin blog.csdn.net/qq_39530692/article/details/112728241