Keil Logo

Language extension compatibility: keywords

4.1 Language extension compatibility: keywords

Arm® Compiler 6 supports some keywords that are supported in Arm Compiler 5.

The following table lists some of the commonly used keywords that Arm Compiler 5 supports 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 table is not an exhaustive list of all keywords.

Table 4-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))

Note:

Older versions of armcc supported the __const keyword. The equivalent for this keyword in Arm Compiler 5 and Arm Compiler 6 is __attribute__((const)).
__attribute__((const)) __attribute__((const))
__forceinline
  • For C90, use __inline__ and __attribute__((always_inline))
  • For other source languages, use inline and __attribute__((always_inline))
See __attribute__((always_inline)).
__global_reg(N)

Use the register and __asm keywords for global named register variables using core registers.

For example: register int Reg5 __asm("r5").

In Arm Compiler 6, you must also use the relevant -ffixed-rN armclang option.

Alternatively, you can use equivalent inline assembler instructions.

__inline(x) __inline__. The use of this keyword depends on the language mode.
__int64 You can use int64_t, which is a 64-bit integer type defined in the header file <stdint.h> (for C source files) or <cstdint> (for C++ source files). You can also use long long, however, if you use long long in C90 mode, the compiler gives:
  • a warning.
  • an error, if you also use -pedantic-errors.
__INTADDR__ No equivalent.
__irq __attribute__((interrupt)). This keyword is not supported in AArch64.
__packed for removing padding within structures.

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

  • The __attribute__((packed)) variable attribute applies to members of a structure or union. It does not apply to variables that are not members of a structure or union.
  • __attribute__((packed)) is not a type qualifier. Taking the address of a packed member can result in unaligned pointers, and usually 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 keyword provides limited functionality when 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 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.
Named register variables for direct manipulation of a core register as if it were a C variable. For example: register int R5 __asm("r5").

Use the register and __asm keywords for global named register variables using core registers.

For example: register int Reg5 __asm("r5").

In Arm Compiler 6, you must also use the relevant -ffixed-rN armclang option.

Named register variables for direct manipulation of a system register, other than core registers, as if it were a C variable. For example: register int fpscr __asm("fpscr"). No equivalent. To access FPSCR, use the __vfp_status intrinsic or inline assembly instructions.

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 4-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 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;}
Non-ConfidentialPDF file icon PDF version100068_0613_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.