3.3 Language extension compatibility: pragmas

ARM® Compiler 6 provides support for some pragmas that are supported in ARM Compiler 5. Other pragmas are not supported, or must be replaced with alternatives.

The following table lists some of the commonly used pragmas that are supported by ARM Compiler 5 but are not supported by ARM Compiler 6. Replace any instances of these pragmas in your code with the recommended alternative.

Table 3-3 Pragma language extensions that must be replaced

Pragma supported by older armcc compiler versions Recommended ARM Compiler 6 alternative
#pragma import (symbol)
asm(" .global symbol\n");
#pragma anon_unions
#pragma no_anon_unions
In C, anonymous structs and unions are a C11 extension which is enabled by default in armclang. If you specify the -pedantic option, the compiler emits warnings about extensions do not match the specified language standard. For example:
armclang --target=aarch64-arm-none-eabi -c -pedantic --std=c90 test.c
  test.c:3:5: warning: anonymous structs are a C11 extension [-Wc11-extensions]
In C++, anonymous unions are part of the language standard, and are always enabled. However, anonymous structs and classes are an extension. If you specify the -pedantic option, the compiler emits warnings about anonymous structs and classes. For example:
armclang --target=aarch64-arm-none-eabi -c -pedantic -xc++  test.c 
  test.c:3:5: warning: anonymous structs are a GNU extension [-Wgnu-anonymous-struct]
Introducing anonymous unions, struct and classes using a typedef is a separate extension in armclang, which must be enabled using the -fms-extensions option.
#pragma arm
#pragma thumb
armclang does not support switching instruction set in the middle of a file. You can use the command line options -marm and -mthumb to specify the instruction set of the whole file.
#pragma arm section armclang does not support setting the sections to be used for code, rodata, rwdata and zidata for the rest of the file. However the __attribute__((section("name"))) attribute can be used to set the section of individual functions and variables.
#pragma diag_default
#pragma diag_suppress
#pragma diag_remark
#pragma diag_warning
#pragma diag_error
The following pragmas provide equivalent functionality for diag_suppress, diag_warning, and diag_error:
  • #pragma clang diagnostic ignored "-Wmultichar"
  • #pragma clang diagnostic warning "-Wmultichar"
  • #pragma clang diagnostic error "-Wmultichar"
Note that these pragmas use armclang diagnostic groups, which do not have a precise mapping to armcc diagnostic tags.
armclang has no equivalent to diag_default or diag_remark. diag_default can be replaced by wrapping the change of diagnostic level with #pragma clang diagnostic push and #pragma clang diagnostic pop, or by manually returning the diagnostic to the default level.
There is an additional diagnostic level supported in armclang, fatal, which causes compilation to fail without processing the rest of the file. You can set this as follows:
#pragma clang diagnostic fatal "-Wmultichar"
#pragma exceptions_unwind
#pragma no_exceptions_unwind
armclang does not support these pragmas.
Use the __attribute__((nothrow)) function attribute instead.
#pragma GCC system_header
This pragma is supported by both armcc and armclang, but #pragma clang system_header is the preferred spelling in armclang for new code.
#pragma hdrstop
#pragma no_pch
armclang does not support these pragmas.
#pragma import(__use_no_semihosting)
#pragma import(__use_no_semihosting_swi)
armclang does not support these pragmas. However, in C code, you can replace these pragmas with asm(" .global __use_no_semihosting\n");
#pragma inline
#pragma no_inline
armclang does not support these pragmas. However, inlining can be disabled on a per-function basis using the __attribute__((noinline)) function attribute.
The default behavior of both armcc and armclang is to inline functions when the compiler considers this worthwhile, and this is the behavior selected by using #pragma inline in armcc. To force a function to be inlined in armclang, use the __attribute__((always_inline)) function attribute.
#pragma Onum
#pragma Ospace
#pragma Otime
armclang does not support changing optimization options within a file. Instead these must be set on a per-file basis using command-line options.
#pragma pop
#pragma push
armclang does not support these pragmas.
If these are only used to control emission of diagnostics, #pragma clang diagnostic push and #pragma clang diagnostic pop can be used to achieve the same effect.
#pragma softfp_linkage
armclang does not support this pragma. Instead, use the __attribute__((pcs("aapcs"))) function attribute to set the calling convention on a per-function basis, or use the -mfloat-abi=soft command-line option to set the calling convention on a per-file basis.
#pragma no_softfp_linkage
armclang does not support this pragma. Instead, use the __attribute__((pcs("aapcs-vfp"))) function attribute to set the calling convention on a per-function basis, or use the -mfloat-abi=hard command-line option to set the calling convention on a per-file basis.
#pragma unroll[(n)]
#pragma unroll_completely
armclang supports these pragmas.
The default for #pragma unroll (that is, with no iteration count specified) differs between armclang and armcc:
  • With armclang, the default is to fully unroll a loop.
  • With armcc, the default is #pragma unroll(4).
Related reference
3.6 C and C++ implementation compatibility
3.1 Language extension compatibility: keywords
3.2 Language extension compatibility: attributes
3.5 Diagnostics for pragma compatibility
Related information
armclang Reference Guide: #pragma GCC system_header
armclang Reference Guide: #pragma once
armclang Reference Guide: #pragma pack(n)
armclang Reference Guide: #pragma weak symbol, #pragma weak symbol1 = symbol2
armclang Reference Guide: #pragma unroll[(n)], #pragma unroll_completely
Non-ConfidentialPDF file icon PDF versionARM DUI0742F
Copyright © 2014-2016 ARM. All rights reserved.