SLAU132V October 2004 – February 2020
The following GCC function attributes are supported:
The following additional TI-specific function attribute is supported:
For example, this function declaration uses the alias attribute to make "my_alias" a function alias for the "myFunc" function:
void my_alias() __attribute__((alias("myFunc")));
The aligned function attribute has the same effect as the CODE_ALIGN pragma. See Section 5.12.5
The always_inline function attribute has the same effect as the FUNC_ALWAYS_INLINE pragma. See Section 5.12.12
The call_conv attribute can be used to modify the calling conventions to allow both the IAR and TI compilers to link against the same ROM image. This function attribute allows functions compiled with the TI compiler to be linked with a ROM image generated by the IAR compiler. Note that the TI compiler does not generate ROM images.
The call_conv attribute can be specified with "cc_rom" (for IAR/TI compatibility) or "cc_norm" (the default calling convention). Use "cc_rom" if you want to share a ROM image compiled with IAR. The following example uses the call_conv attribute in several ways:
#define __cc_rom __attribute__((call_conv("cc_rom")))
__cc_rom void rom_func(void)
{
...
}
typedef __cc_rom void (rom_func_t)(void);
int main()
{
rom_func();
rom_func_t *fp = (rom_func_t*)0x1234;
fp();
((void (__cc_rom *)(void))0x2468)();
void (__cc_rom *rom_func_ptr)(void);
rom_func_ptr = &rom_func;
rom_func_ptr();
}
If you want IAR/TI compatibility with your calling conventions, be aware of the following restrictions on parameter passing.
The calls attribute has the same effect as the CALLS pragma, which is described in Section 5.12.2.
The format attribute is applied to the declarations of printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf, scanf, fscanf, vfscanf, vscanf, vsscanf, and sscanf in stdio.h. Thus when GCC extensions are enabled, the data arguments of these functions are type checked against the format specifiers in the format string argument and warnings are issued when there is a mismatch. These warnings can be suppressed in the usual ways if they are not desired.
See Section 5.12.20 for more about using the interrupt function attribute.
The malloc attribute is applied to the declarations of malloc, calloc, realloc and memalign in stdlib.h.
The naked attribute identifies functions that are written as embedded assembly functions using __asm statements. The compiler does not generate prologue and epilog sequences for such functions. See Section 5.11.
The noinline function attribute has the same effect as the FUNC_CANNOT_INLINE pragma. See Section 5.12.13
The ramfunc attribute specifies that a function will be placed in and executed from RAM. The ramfunc attribute allows the compiler to optimize functions for RAM execution, as well as to automatically copy functions to RAM on flash-based devices. For example:
__attribute__((ramfunc))
void f(void) {
...
}
The --ramfunc=on option specifies that all functions compiled with this option are placed in and executed from RAM, even if this function attribute is not used.
Newer TI linker command files support the ramfunc attribute automatically by placing functions with this attribute in the .TI.ramfunc section. If you have a linker command file that does not include a section specification for the .TI.ramfunc section, you can modify the linker command file to place this section in RAM. See the Placing functions in RAM wiki page for more about the ramfunc attribute and option. See the MSP430 Assembly Language Tools User's Guide for details on section placement.
The retain attribute has the same effect as the RETAIN pragma (Section 5.12.29). That is, the section that contains the function will not be omitted from conditionally linked output even if it is not referenced elsewhere in the application.
The section attribute when used on a function has the same effect as the CODE_SECTION pragma. See Section 5.12.6
The weak attribute has the same effect as the WEAK pragma (Section 5.12.32).