Microchip Technology SW006023-2 Scheda Tecnica

Pagina di 238
Supported Data Types and Variables
 2012 Microchip Technology Inc.
DS51686E-page 107
space (space)
The space attribute can be used to direct the compiler to allocate a variable in 
specific memory spaces.
unique_section
Place the variable in a uniquely named section, just as if -fdata-sections had been 
specified. If the variable also has a section attribute, use that section name as the 
prefix for generating the unique section name.
For example,
int tin __attribute__ ((section (“.ofcatfood”), unique_section)
Variable tin will be placed in section .ofcatfood.
unused
Indicate to the compiler that the variable may not be used. The compiler will not issue 
a warning for this variable if it is not used.
weak
The weak attribute causes the declaration to be emitted as a weak symbol. A weak 
symbol indicates that if a global version of the same symbol is available, that version 
should be used instead.
When weak is applied to a reference to an external symbol, the symbol is not required 
for linking. For example:
extern int _ _attribute_ _((_ _weak_ _)) s;
int foo() {
  if (&s) return s;
  return 0; /* possibly some other value */
}
In the above program, if s is not defined by some other module, the program will still 
link but s will not be given an address. The conditional verifies that s has been defined 
(and returns its value if it has). Otherwise ‘0’ is returned. There are many uses for this 
feature, mostly to provide generic code that can link with an optional library.