In MPLAB IDE what is the sizes of data types (int, unsigned int, float, unsigned float, char...)?
MPLAB IDE data type sizes
33.1k Views Asked by srinath reddy AtThere are 5 best solutions below
On
I would be wary of such generalizations. MPLAB is just an IDE - it is suitable for different chips. Microchip has 8-bit controllers like PIC18F, 16-bit and 32-bit controllers. The data types for each may be different and hold serious implications for performance. I.e. for the 8-bit chips the 16 and 32 bit data types may be emulated in software, which isn't always what you want.
On
Values for int, long, etc., are never standardly defined across all compilers(reference) . For this reason, it is advised to make use of the library:
#include <stdint.h>
To make use of this library for your own purposes, try using the code as follows:
typedef uint8_t BYTE
typedef uint16_t WORD
typedef uint32_t LONG
Then you just use these to define your variables. This method usually makes use of an integer.h file to store these definitions and is included wherever needed.



This is hard without knowing for which CPU you want to compile code. Assuming e.g. Microchip's C18 compiler for the PIC18, the User Guide states the following fundamental type sizes:
Note that this includes some types (
short long) that are not standard in C.