6.9.1 Implementation-Defined Limit Macros

Include

<limits.h>

Remarks

The macros in the following table relate to the sizes of the integer types and expand to constant expressions that can be used in the controlling expression with #if preprocessor directives.

The baseline and non-enhanced mid-range PIC devices supported by MPLAB XC8 do not implement 64-bit integer types, and all the long long int integer types are 32 bits wide for these devices. For all other devices, regardless of compiler utilized, the long long int types are 64-bit wide.

Table 6-4. Declarations Provided by <limits.h>
Macro NameDescriptionValue
CHAR_BITNumber of bits to represent type char8
CHAR_MAXMaximum value of a char

When -funsigned-char is in effect (or using XC8 for PIC devices and no plain char type option has been used): 255

When -fsigned-char is in effect (or using any other compiler and no plain char type option has been used): 127

CHAR_MINMinimum value of a char

When -funsigned-char is in effect (or using XC8 for PIC devices and no plain char type option has been used): 0

When -fsigned-char is in effect (or using any other compiler and no plain char type option has been used): -128

UCHAR_MAXMaximum value of an unsigned char255
SCHAR_MAXMaximum value of a signed char127
SCHAR_MINMinimum value of a signed char-128
USHRT_MAXMaximum value of an unsigned short int65535
SHRT_MAX Maximum value of a short int32767
SHRT_MIN Minimum value of a short int-32768
UINT_MAXMaximum value of an unsigned int

MPLAB XC8: 65535

MPLAB XC-DSC (dsPIC33A devices): 4294967295

MPLAB XC16 and XC-DSC (other devices): 65535

MPLAB XC32: 4294967295

INT_MAXMaximum value of a int

MPLAB XC8: 32767

MPLAB XC-DSC (dsPIC33A devices): 2147483647

MPLAB XC16 and XC-DSC (other devices): 32767

MPLAB XC32: 2147483647

INT_MINMinimum value of a int

MPLAB XC8: -32768

MPLAB XC-DSC (dsPIC33A devices): -2147483648

MPLAB XC16 and XC-DSC (other devices): -32768

MPLAB XC32: -2147483648

ULONG_MAXMaximum value of a long unsigned int4294967295
LONG_MAXMaximum value of a long int2147483647
LONG_MINMinimum value of a long int-2147483648
ULLONG_MAXMaximum value of a long long unsigned int

Devices lacking 64 bit support (see Remarks): 4294967295

All other devices: 18446744073709551615

LLONG_MAXMaximum value of a long long int

Devices lacking 64 bit support (see Remarks): 2147483647

All other devices: 9223372036854775807

LLONG_MINMinimum value of a long long int

Devices lacking 64 bit support (see Remarks): -2147483648

All other devices: -9223372036854775808

MB_LEN_MAX Maximum number of bytes in a multibyte character

MPLAB XC8: 1

MPLAB XC16 and XC-DSC: 4

MPLAB XC32: 16