Microchip Technology SW006023-2 Hoja De Datos
MPLAB
®
XC32 C/C++ Compiler User’s Guide
DS51686E-page 24
2012 Microchip Technology Inc.
2.4.7
Plain
char
Types
The type of a plain char is unsigned char. It is generally recommended that all def-
initions for the char type explicitly state the signedness of the object.
initions for the char type explicitly state the signedness of the object.
2.4.7.1
EXAMPLE
The following example
char foobar;
defines an unsigned char object called foobar.
2.4.7.2
DIFFERENCES
The 8-bit compilers have always treated plain char as an unsigned type.
The 16- and 32-bit compilers used signed char as the default plain char type. The
-funsigned-char
-funsigned-char
option on those compilers changed the default type to be
unsigned char
.
2.4.7.3
MIGRATION TO THE CCI
Any definition of an object defined as a plain char and using the 16- or 32-bit compilers
needs review. Any plain char that was intended to be a signed quantity should be
replaced with an explicit definition, for example.
needs review. Any plain char that was intended to be a signed quantity should be
replaced with an explicit definition, for example.
signed char foobar;
You may use the -funsigned-char option on XC16/32 to change the type of plain
char
char
, but since this option is not supported on XC8, the code is not strictly conforming.
2.4.8
Signed Integer Representation
The value of a signed integer is determined by taking the two’s complement of the inte-
ger.
ger.
2.4.8.1
EXAMPLE
The following shows a variable, test, that is assigned the value -28 decimal.
signed char test = 0xE4;
2.4.8.2
DIFFERENCES
All compilers have represented signed integers in the way described in this section.
2.4.8.3
MIGRATION TO THE CCI
No action required.