Skip to main content

IAR Embedded Workbench for RISC-V 3.40

Object attributes

In this section:

Normally, object attributes affect the internal functionality of functions and data objects, but not directly how the function is called or how the data is accessed. This means that an object attribute does not normally need to be present in the declaration of an object. Any exceptions to this rule are noted in the description of the attribute.

These object attributes are available:

  • Object attributes that can be used for variables:

    __no_alloc, __no_alloc16, __no_alloc_str, __no_alloc_str16, __no_init, __ro_placement

  • Object attributes that can be used for functions and variables:

    location, @, __root, __weak

  • Object attributes that can be used for functions:

    __intrinsic, __noreturn, vector

You can specify as many object attributes as required for a specific function or data object.

For more information about location and @, see Controlling data and function placement in memory. For more information about vector, see vector.

Syntax for object attributes

The object attribute must be placed in front of the type. For example, to place myarray in memory that is not initialized at startup:

__no_init int myarray[10]; 

The #pragmaobject_attribute directive can also be used. This declaration is equivalent to the previous one:

#pragma object_attribute=__no_init
int myarray[10];

Note

Object attributes cannot be used in combination with the typedef keyword.