Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
Common C Interface
 2012 Microchip Technology Inc.
DS52053A-page 19
2.4.5
The Number of Significant Initial Characters in an Identifier
At least the first 255 characters in an identifier (internal and external) are significant. 
This extends upon the requirement of the ANSI C Standard which states a lower num-
ber of significant characters are used to identify an object.
2.4.5.1
EXAMPLE
The following example shows two poorly named variables, but names which are 
considered unique under the CCI.
int stateOfPortBWhenTheOperatorHasSelectedAutomaticModeAndMotorIsRunningFast;
int stateOfPortBWhenTheOperatorHasSelectedAutomaticModeAndMotorIsRunningSlow;
2.4.5.2
DIFFERENCES
Former 8-bit compilers used 31 significant characters by default, but an option allowed 
this to be extended.
The 16- and 32-bit compilers did not impose a limit on the number of significant char-
acters.
2.4.5.3
MIGRATION TO THE CCI
No action required. You may take advantage of the less restrictive naming scheme.
2.4.6
Sizes of Types
The sizes of the basic C types, for example char, int and long, are not fully defined 
by the CCI. These types, by design, reflect the size of registers and other architectural 
features in the target device. They allow the device to efficiently access objects of this 
type. The ANSI C Standard does, however, indicate minimum requirements for these 
types, as specified in <limits.h>.
If you need fixed-size types in your project, use the types defined in <stdint.h>, e.g., 
uint8_t
 or int16_t. These types are consistently defined across all XC compilers, 
even outside of the CCI.
Essentially, the C language offers a choice of two groups of types: those that offer sizes 
and formats that are tailored to the device you are using; or those that have a fixed size, 
regardless of the target.
2.4.6.1
EXAMPLE
The following example shows the definition of a variable, native, whose size will allow 
efficient access on the target device; and a variable, fixed, whose size is clearly indi-
cated and remains fixed, even though it may not allow efficient access on every device.
int native;
int16_t fixed;
2.4.6.2
DIFFERENCES
This is consistent with previous types implemented by the compiler.
2.4.6.3
MIGRATION TO THE CCI
If you require a C type that has a fixed size, regardless of the target device, use one of 
the types defined by <stdint.h>.