首页 > 代码库 > Keil MDK编译器的数据类型定义

Keil MDK编译器的数据类型定义

 1 #include "usart.h" 2 int main() 3 { 4     USART1_Config();    //串口初始化,以下信息通过串口打印 5     printf("char: %d\r\n",sizeof(char)); 6     printf("unsigned char: %d\r\n",sizeof(unsigned char)); 7     printf("short: %d\r\n",sizeof(short)); 8     printf("unsigned short: %d\r\n",sizeof(unsigned short)); 9     printf("int: %d\r\n",sizeof(int));10     printf("unsigned int: %d\r\n",sizeof(unsigned int));11     printf("long: %d\r\n",sizeof(long));12     printf("unsigned long: %d\r\n",sizeof(unsigned long));13     printf("float: %d\r\n",sizeof(float));14     printf("double: %d\r\n",sizeof(double));15     while(1);16 }

通过以上一段代码,得到了Keil MDK编译器对常用数据类型长度的定义。

结果如下:

char: 1
unsigned char: 1
short: 2
unsigned short: 2
int: 4
unsigned int: 4
long: 4
unsigned long: 4
float: 4
double: 8