在MPLAB IDE中,数据类型(int、unsigned int、float、unsigned float、char...)的大小是多少?
发布于 2009-11-10 18:25:43
如果不知道要为哪个CPU编译代码,这是很困难的。假设Microchip针对PIC18的C18编译器,User Guide规定了以下基本类型大小:
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请注意,这包括一些不是C语言标准的类型(short long)。
发布于 2016-01-21 20:31:24
int、long等的值永远不会在所有编译器(reference)中进行标准化定义。因此,建议使用该库:
#include <stdint.h>要将该库用于您自己的目的,请尝试使用以下代码:
typedef uint8_t BYTE
typedef uint16_t WORD
typedef uint32_t LONG然后你只需要用它们来定义你的变量。此方法通常使用一个整型.h文件来存储这些定义,并在需要时包含在其中。
发布于 2017-11-23 14:18:43
下面是整数数据类型在不同MPLAB XC编译器上的实现。
8位设备的

16位设备的

32位设备的

https://stackoverflow.com/questions/1706933
复制相似问题