Keil Logo

Language extension compatibility: attributes

4.2 Language extension compatibility: attributes

Arm® Compiler 6 provides support for some function, variable, and type attributes that were supported in Arm Compiler 5. Other attributes are not supported, or have an alternate implementation.

The following attributes are supported by Arm Compiler 5 and Arm Compiler 6. These attributes do not require modification in your code:

Note:

The __declspec keyword is deprecated.
  • __attribute__((aligned(x)))
  • __attribute__((const))
  • __attribute__((deprecated))
  • __attribute__((noinline))
  • __declspec(noinline)
  • __attribute__((nonnull))
  • __attribute__((noreturn))
  • __declspec(noreturn)
  • __attribute__((nothrow))
  • __declspec(nothrow)
  • __attribute__((pcs("calling convention")))
  • __attribute__((pure))
  • __attribute__((unused))
  • __attribute__((used))
  • __attribute__((visibility))
  • __attribute__((weak))
  • __attribute__((weakref))

Though Arm Compiler 6 supports certain __declspec attributes, Arm recommends using __attribute__ where available.

Table 4-3 Support for __declspec attributes

declspec supported by Arm Compiler 5 Recommended Arm Compiler 6 alternative
__declspec(dllimport) None. There is no support for BPABI linking models.
__declspec(dllexport) None. There is no support for BPABI linking models.
__declspec(noinline) __attribute__((noinline))
__declspec(noreturn) __attribute__((noreturn))
__declspec(nothrow) __attribute__((nothrow))
__declspec(notshared) None. There is no support for BPABI linking models.
__declspec(thread) __thread

__attribute__((always_inline))

__attribute__((always_inline)) is supported by Arm Compiler 5 and Arm Compiler 6. However, this attribute might require modification in your code.

When using Arm Compiler 5, __attribute__((always_inline)) affects the linkage of the function according to the inline semantics of the source language.

When using Arm Compiler 6, __attribute__((always_inline)) does not affect the linkage of the function. To change the linkage according to the inline semantics, you must use the keyword inline or __inline__ (for C90). For more information, see __attribute__((always_inline)).

Section

__attribute__((section("name"))) is supported by Arm Compiler 5 and Arm Compiler 6. However, this attribute might require modification in your code.

When using Arm Compiler 5, section names do not need to be unique. Therefore, you could use the same section name to create different section types.

Arm Compiler 6 supports multiple sections with the same section name only if you specify a unique ID. You must ensure that different section types either:

  • Have a unique section name.
  • Have a unique ID, if they have the same section name.

If you use the same section name, for another section or symbol, without a unique ID, then armclang integrated assembler merges the sections and gives the merged section the flags of the first section with that name.

Migrating __attribute__((at(address))) and zero-initialized __attribute__((section("name"))) from Arm® Compiler 5 to Arm® Compiler 6

Arm Compiler 5 supports the following attributes, which Arm Compiler 6 does not support:

  • __attribute__((at(address))) to specify the absolute address of a function or variable.
  • __attribute__((at(address), zero_init)) to specify the absolute address of a zero-initialized variable.
  • __attribute__((section(name), zero_init)) to place a zero-initialized variable in a zero-initialized section with the given name.
  • __attribute__((zero_init)) to generate an error if the variable has an initializer.

The following table shows migration paths for these features using Arm Compiler 6 supported features:

Table 4-4 Migrating __attribute__((at(address))) and zero-initialized __attribute__((section("name")))

Arm Compiler 5 attribute Arm Compiler 6 attribute Description
__attribute__((at(address))) __attribute__((section(".ARM.__at_address"))) armlink in Arm Compiler 6 still supports the placement of sections in the form of .ARM.__at_address
__attribute__((at(address), zero_init)) __attribute__((section(".bss.ARM.__at_address"))) armlink in Arm Compiler 6 supports the placement of zero-initialized sections in the form of .bss.ARM.__at_address. The .bss prefix is case sensitive and must be all lowercase.
__attribute__((section(name), zero_init)) __attribute__((section(".bss.name"))) name is a name of your choice. The .bss prefix is case sensitive and must be all lowercase.
__attribute__((zero_init)) Arm Compiler 6 by default places zero-initialized variables in a .bss section. However, there is no equivalent to generate an error when you specify an initializer. Arm Compiler 5 generates an error if the variable has an initializer. Otherwise, it places the zero-initialized variable in a .bss section.
Non-ConfidentialPDF file icon PDF version100068_0612_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.