Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
C Language Features
 2012 Microchip Technology Inc.
DS52053B-page 163
This qualifier is controlled by the compiler option --ADDRQUAL, which determines its 
effect, see Section 4.8.16 “--ADDRQUAL: Set Compiler Response to Memory 
Qualifiers”
. Based on this option’s settings, this qualifier may be binding or ignored 
(which is the default operation). Qualifiers which are ignored will not produce an error 
or warning, but will have no effect.
Here is an example of an unsigned char object qualified as near:
near unsigned char fred;
Objects qualified near cannot be auto or parameters to a function, but can be quali-
fied static, allowing them to be defined locally within a function, as in:
void myFunc(void) {
static near unsigned char local_fred;
Note that the compiler may store some temporary objects in the common memory, so 
not all of this space may be available for user-defined variables.
If the xc8 option, --STRICT is used, this type qualifier is changed to __near.
5.4.8.3
FAR TYPE QUALIFIER
The far type qualifier is used to place non-auto variables into the program memory 
space for those PIC18 devices which can support external memory. It will be ignored 
when compiling for PIC10/12/16 targets. The compiler assumes that variables will be 
located in RAM which is implemented in this memory space.
Access of far variables are less efficient than that of internal variables and will result 
in larger, slower code.
This qualifier is controlled by the compiler option --ADDRQUAL, which determines its 
effect on PIC18 devices, see Section 4.8.16 “--ADDRQUAL: Set Compiler 
Response to Memory Qualifiers”
. Based on this option’s settings, this qualifier may 
be binding or ignored (which is the default operation). Qualifiers which are ignored will 
not produce an error or warning, but will have no effect.
Here is an example of an unsigned int object placed into the device’s external pro-
gram memory space:
far unsigned int farvar;
Objects qualified far cannot be auto or parameters to a function, but can be qualified 
static
, allowing them to be defined locally within a function, as in:
void myFunc(void) {
static far unsigned char local_far;
If the --STRICT is used, this type qualifier is changed to __far.
Note that not all PIC18 devices support external memory in their program memory 
space and, thus, the far qualifier is not applicable to all PIC18 devices. On supported 
devices, the address range where the additional memory will be mapped must first be 
specified with the --RAM option, Section 4.8.48 “--RAM: Adjust RAM Ranges”. For 
example, to map additional data memory from 20000h to 2FFFFh use
--RAM=default,+20000-2FFFF.
5.4.8.4
BANK0, BANK1, BANK2 AND BANK3 TYPE QUALIFIERS
The bank0, bank1, bank2 and bank3 type qualifiers are recognized by the compiler 
and allow some degree of control of the placement of objects in the device’s data mem-
ory banks. When compiling for PIC18 targets, these qualifiers are only accepted for 
portability and have no effect on variable placement; on other devices they can be used 
to define C objects that are assumed to be located in certain memory banks by 
hand-written assembly code. The compiler automatically allocates variables to all data 
banks, so these qualifiers are not normally needed.