4.11 default_function_attributes Pragma

The IAR default_function_attributes pragma sets default segment placement, type attributes, and object attributes for function declarations and definitions that do not otherwise specify type or object attributes or location.

Suggested Replacement

There is no equivalent MPLAB XC8 pragma. Some of this pragma's functionality can be achieved with an attribute.

The MPLAB XC8 section attribute can be used with functions to specify the section in which it is placed. If the Common C Interface is enabled, you can instead use the __section specifier.

Caveats

The sections generated by this attribute are not concatenated across translation units by the linker, and the -Wl,--section-start,section_name=address option, which can place a section in memory, only works with custom (non-standard) sections.

Examples

Consider migrating IAR code such as:
#pragma default_function_attributes = @ "SP_SEG"
int inc(int x)
{
    return x + 1;
}
#pragma default_function_attributes =
to MPLAB XC8 code similar to:
#include <xc.h>

int __section("SP_SEG") inc(int x)
{
    return x + 1;
}
and build with the -mext=cci option.

Further Information

See the Attributes and Ext Option section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on this attribute.