MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
16-Bit C <strong>Compiler</strong> User’s Guide<br />
noload<br />
The noload attribute indicates that space should be allocated <strong>for</strong> the function, but that<br />
the actual code should not be loaded into memory. This attribute could be useful if an<br />
application is designed to load a function into memory at run time, such as from a serial<br />
EEPROM.<br />
void bar() __attribute__ ((noload)) {<br />
...<br />
}<br />
noreturn<br />
A few st<strong>and</strong>ard library functions, such as abort <strong>and</strong> exit, cannot return. The compiler<br />
knows this automatically. Some programs define their own functions that never<br />
return. You can declare them noreturn to tell the compiler this fact. For example:<br />
void fatal (int i) __attribute__ ((noreturn));<br />
void<br />
fatal (int i)<br />
{<br />
/* Print error message. */<br />
exit (1);<br />
}<br />
The noreturn keyword tells the compiler to assume that fatal cannot return. It can<br />
then optimize without regard to what would happen if fatal ever did return. This<br />
makes slightly better code. Also, it helps avoid spurious warnings of uninitialized<br />
variables.<br />
It does not make sense <strong>for</strong> a noreturn function to have a return type other than void.<br />
section ("section-name")<br />
Normally, the compiler places the code it generates in the .text section. Sometimes,<br />
however, you need additional sections, or you need certain functions to appear in<br />
special sections. The section attribute specifies that a function lives in a particular<br />
section. For example, consider the declaration:<br />
extern void foobar (void) __attribute__ ((section (".libtext")));<br />
This puts the function foobar in the .libtext section.<br />
The section attribute conflicts with the address attribute. The section name will be<br />
ignored with a warning.<br />
secure<br />
This attribute directs the compiler to allocate a function in the secure segment of<br />
program Flash.<br />
For example, to declare a protected function:<br />
void __attribute__((secure)) func();<br />
An optional argument can be used to specify a protected access entry point within the<br />
secure segment. The argument may be a literal integer in the range 0 to 31 (except<br />
16), or the word unused. Integer arguments correspond to 32 instruction slots in the<br />
segment access area, which occupies the lowest address range of each secure segment.<br />
The value 16 is excluded because access entry 16 is reserved <strong>for</strong> the secure<br />
segment interrupt vector. The value unused is used to specify a function <strong>for</strong> all of the<br />
unused slots in the access area.<br />
DS51284H-page 24 © 2008 <strong>Microchip</strong> Technology Inc.