Microchip Technology SW006023-2N データシート

ページ / 238
MPLAB
®
 XC32 C/C++ COMPILER
USER’S GUIDE
 2012 Microchip Technology Inc.
DS51686E-page 123
Chapter 10.  Functions
The following sections describe how function definitions are written, and specifically 
how they can be customized to suit your application. The conventions used for param-
eters and return values, as well as the assembly call sequences are also discussed.
10.1
WRITING FUNCTIONS
Functions may be written in the usual way in accordance with the C/C++ language.
The only specifier that has any effect on function is static. Interrupt functions are 
defined with the use of the interrupt attribute, see Section 10.2 “Function Attributes 
and Specifiers”
.
A function defined using the static specifier only affects the scope of the function, i.e. 
limits the places in the source code where the function may be called. Functions that 
are static may only be directly called from code in the file in which the function is 
defined. The equivalent symbol used in assembly code to represent the function may 
change if the function is static, seSection 7.3.2 “Static Variables”. This specifier 
does not change the way the function is encoded.
10.2
FUNCTION ATTRIBUTES AND SPECIFIERS
10.2.1
Function Attributes
address(addr)
The address attribute specifies an absolute virtual address for the function. Be sure to 
specify the address attribute using an appropriate virtual address for the target device. 
The address is typically in the range [0x9D000000,0x9D0FFFFC], as defined in the 
linker script as the ‘kseg0_program_mem’ memory region. For example,
__attribute__((address(0x9D008000))) void bar (void);
The compiler performs no error checking on the address. The section containing the 
function will be located at the specified address regardless of the memory-regions 
specified in the linker script or the actual memory ranges on the target device. The 
application code must ensure that the address is valid for the target device.