Data Type Definition of the Keil MDK compiler.
1 # include "usart. h "2 int main () 3 {4 usartmediaconfig (); // serial port initialization, the following information is printed through the serial port 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}
The preceding Code defines the length of common data types in the Keil MDK compiler.
The result is as follows:
Char: 1
Unsigned char: 1
Short: 2
Unsigned short: 2
Int: 4
Unsigned int: 4
Long: 4
Unsigned long: 4
Float: 4
Double: 8
How many data types are defined by the keil compiler?
Method 1: Use the sizeof operator directly in the Code. For example, if a = sizeof (int), the value of a is the length of an int.
Method 2: After compilation is successful, open the. map File (or. m51) and find the SYMBOL.
For example:
00000036 h symbol data byte temp
00000037 h symbol data byte temp2
Temp, temp2 is the variable name, 00036H is the starting address of the variable, DATA indicates that the variable is in the data area, and BYTE indicates that the variable is in the BYTE type, that is, a BYTE. You can calculate the length by the address difference of different variables.
Does the int32_t type in the keil mdk already exist by default?
In general, keil does not contain the Type Definitions. If it is in a program compiled by someone else, maybe he has a defined type alias, maybe you did not include the response header file yourself, in fact, you can also define it by yourself, which is not very troublesome.
The advantage of doing so is that there is no need to write a long string of types each time to simplify the purpose of the program. This alias is also very nice. At first glance, we know it is a 32-bit integer, as long as you can know what he is, it's easy to change and there's no need to be too entangled!