如果不知道要编译代码的CPU,这很难.假设用于PIC18的Microchip的C18编译器,用户指南指出了以下基本类型大小:
TYPE SIZE RANGE
char(1,2) 8 bits -128 127
signed char 8 bits -128 127
unsigned char 8 bits 0 255
int 16 bits -32,768 32,767
unsigned int 16 bits 0 65,535
short 16 bits -32,768 32,767
unsigned short 16 bits 0 65,535
short long 24 bits -8,388,608 8,388,607
unsigned short long 24 bits 0 16,777,215
long 32 bits -2,147,483,648 2,147,483,647
unsigned long 32 bits 0 4,294,967,295
Run Code Online (Sandbox Code Playgroud)
请注意,这包括一些short long在C中不标准的类型().