You copied the Doc URL to your clipboard.

Arm Compiler Migration and Compatibility Guide : Language extension compatibility: keywords

Language extension compatibility: keywords

Arm® Compiler 6 provides support for some keywords that are supported in Arm Compiler 5.

Note

This topic includes descriptions of [COMMUNITY] features. See Support level definitions.

The following table lists some of the commonly used keywords that are supported by Arm Compiler 5 and shows whether Arm Compiler 6 supports them using __attribute__. Replace any instances of these keywords in your code with the recommended alternative where available or use inline assembly instructions.

Note

This is not an exhaustive list of all keywords.

Table 3-1 Keyword language extensions in Arm Compiler 5 and Arm Compiler 6

Keyword supported by Arm Compiler 5 Recommended Arm Compiler 6 keyword or alternative
__align(x) __attribute__((aligned(x)))
__alignof__ __alignof__
__ALIGNOF__ __alignof__
Embedded assembly using __asm Arm Compiler 6 does not support the __asm keyword on function definitions and declarations for embedded assembly. Instead, you can write embedded assembly using the __attribute__((naked)) function attribute. See __attribute__((naked)).
__const __attribute__((const))
__attribute__((const)) __attribute__((const))
__forceinline __attribute__((always_inline))
__global_reg Use inline assembler instructions or equivalent routine.
__inline(x) __inline__. The use of this depends on the language mode.
__int64 No equivalent. However, you can use long long. When you use long long in C90 mode, the compiler gives:
  • a warning.
  • an error, if you also use -pedantic-errors.
__INTADDR

[COMMUNITY] None. There is community support for this as a Clang builtin.

__irq __attribute__((interrupt)). This is not supported in AArch64.
__packed for removing padding within structures.

__attribute__((packed)). This provides limited functionality compared to __packed:

  • The __attribute__((packed)) variable attribute applies to members of a structure or union, but it does not apply to variables that are not members of a struct or union.
  • __attribute__((packed)) is not a type qualifier. Taking the address of a packed member can result in unaligned pointers, and in most cases the compiler generates a warning. Arm recommends upgrading this warning to an error when migrating code that uses __packed. To upgrade the warning to error, use the armclang option -Werror=name.

The placement of the attribute is different from the placement of __packed. If your legacy code contains typedef __packed struct, then replace it with:

typedef struct __attribute__((packed))
__packed as a type qualifier for unaligned access. __unaligned. This provides limited functionality compared to the __packed type qualifier.

The __unaligned type qualifier can be used over a structure only when using typedef or when declaring a structure variable. This limitation does not apply when using __packed in Arm Compiler 5. Therefore, there is currently no migration for legacy code that contains __packed struct S{...};.

__pure __attribute__((const))
__smc Use inline assembler instructions or equivalent routine.
__softfp __attribute__((pcs("aapcs")))
__svc Use inline assembler instructions or equivalent routine.
__svc_indirect Use inline assembler instructions or equivalent routine.
__svc_indirect_r7 Use inline assembler instructions or equivalent routine.
__thread __thread
__value_in_regs __attribute__((value_in_regs))
__weak __attribute__((weak))
__writeonly No equivalent.

Note

The __const keyword was supported by older versions of armcc. The equivalent for this keyword in Arm Compiler 5 and Arm Compiler 6 is __attribute__((const)).

Migrating the __packed keyword from Arm® Compiler 5 to Arm® Compiler 6

The __packed keyword in Arm Compiler 5 has the effect of:

  • Removing the padding within structures.
  • Qualifying the variable for unaligned access.

Arm Compiler 6 does not support __packed, but supports __attribute__((packed)) and __unaligned keyword. Depending on the use, you might need to replace __packed with both __attribute__((packed)) and __unaligned. The following table shows the migration paths for various uses of __packed.

Table 3-2 Migrating the __packed keyword

Arm Compiler 5 Arm Compiler 6
__packed int x; __unaligned int x;
__packed int *x; __unaligned int *x;
int * __packed x; int * __unaligned x;
__unaligned int * __packed x; __unaligned int * __unaligned x;
typedef __packed struct S{...} s; typedef __unaligned struct __attribute__((packed)) S{...} s;
__packed struct S{...}; There is currently no migration. Use a typedef instead.
__packed struct S{...} s;

__unaligned struct __attribute__((packed)) S{...} s;

Subsequent declarations of variables of type struct S must use __unaligned, for example __unaligned struct S s2.

struct S{__packed int a;} struct S {__attribute__((packed)) __unaligned int a;}