Supported GCC attributes
In extended language mode—when either --language=extended or --language=gnu has been specified—the IAR C/C++ Compiler also supports a limited selection of GCC-style attributes. Use the __attribute__ ((attribute-list)) syntax for these attributes.
The following attributes are supported in part or in whole. For more information, see the GCC documentation.
aliasalignedThis attribute is supported on:
typedefdeclarationsenumtypesstructanduniontypes and membersvariables, except register variables.
In contrast to the GCC implementation, the attribute is neither supported on functions nor on (pointer) function parameters. Additional limitations might also apply, such as auto variables not being allowed to have a stricter alignment than the stack.
always_inlineIn contrast to the GCC implementation, the attribute implies
inlineon the function, and no diagnostic message will be produced whenalways_inlineis used on a non-inline function.coldThis attribute sets the optimization goal for the function to optimizing for Size. If the optimization goal has also been set using
#pragma optimize, the GCC-style attribute overrides it. If there is a conflict, a warning will be issued.In contrast to the GCC implementation, the attribute can only be used as a function attribute, not in a label.
constconstructorFunctions with the attribute
constructorwill be called at the end of dynamic initialization—after static initialization, and beforemainis called. If the attribute is used on multiple functions, they will be called in the order of definition.deprecatedformathotThis attribute sets the optimization goal for the function to optimizing for Speed. If the optimization goal has also been set using
#pragma optimize, the GCC-style attribute overrides it. If there is a conflict, a warning will be issued.In contrast to the GCC implementation, the attribute can only be used as a function attribute, not in a label.
noinitIn contrast to the GCC implementation, the attribute only applies to variables, and any such variable is treated as if it were declared with the IAR
__no_initkeyword.noinlinenonnullThe attribute is recognized but has no effect.
noreturnpackedWhen used on an enum definition, the smallest possible underlying type is selected for the enum.
Note that when using the GCC-style attribute
packed, no diagnostics messages are produced for potential unalignedstructmember accesses. To be informed of such accesses, use the IAR type attribute__packed.pcs(for IAR type attributes used on functions)puresectiontarget(for IAR object attributes used on functions)unusedusedvolatilewarn_unused_resultweakNote that when the IAR attribute
__weakis used on a declaration or on a tentative definition with a subsequent definition, the object is not made weak. Using the GCC-style attributeweak, the object will be made weak.