Armclang Reference Guide 100067 0608 00 En
Armclang Reference Guide 100067 0608 00 En
Version 6.8
ARM® Compiler
armclang Reference Guide
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.
Release Information
Document History
Your access to the information in this document is conditional upon your acceptance that you will not use or permit others to use
the information for the purposes of determining whether implementations infringe any third party patents.
THIS DOCUMENT IS PROVIDED “AS IS”. ARM PROVIDES NO REPRESENTATIONS AND NO WARRANTIES,
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, SATISFACTORY QUALITY, NON-INFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE
WITH RESPECT TO THE DOCUMENT. For the avoidance of doubt, ARM makes no representation with respect to, and has
undertaken no analysis to identify or understand the scope and content of, third party patents, copyrights, trade secrets, or other
rights.
TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL ARM BE LIABLE FOR ANY DAMAGES,
INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR
CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING
OUT OF ANY USE OF THIS DOCUMENT, EVEN IF ARM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
This document consists solely of commercial items. You shall be responsible for ensuring that any use, duplication or disclosure of
this document complies fully with any relevant export laws and regulations to assure that this document or any portion thereof is
not exported, directly or indirectly, in violation of such export laws. Use of the word “partner” in reference to ARM’s customers is
not intended to create or refer to any partnership relationship with any other company. ARM may make changes to this document at
any time and without notice.
If any of the provisions contained in these terms conflict with any of the provisions of any signed written agreement covering this
document with ARM, then the signed written agreement prevails over and supersedes the conflicting provisions of these terms.
This document may be translated into other languages for convenience, and you agree that if there is any conflict between the
English version of this document and any translation, the terms of the English version of the Agreement shall prevail.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2
Non-Confidential
ARM® Compiler
Words and logos marked with ® or ™ are registered trademarks or trademarks of ARM Limited or its affiliates in the EU and/or
elsewhere. All rights reserved. Other brands and names mentioned in this document may be the trademarks of their respective
owners. Please follow ARM’s trademark usage guidelines at http://www.arm.com/about/trademark-usage-guidelines.php
LES-PRE-20349
Additional Notices
Some material in this document is based on IEEE 754-1985 IEEE Standard for Binary Floating-Point Arithmetic. The IEEE
disclaims any responsibility or liability resulting from the placement and use in the described manner.
Confidentiality Status
This document is Non-Confidential. The right to use, copy and disclose this document may be subject to license restrictions in
accordance with the terms of the agreement entered into by ARM and the party that ARM delivered this document to.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3
Non-Confidential
Contents
ARM® Compiler armclang Reference Guide
Preface
About this book ..................................................... ..................................................... 12
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4
Non-Confidential
1.20 -fomit-frame-pointer, -fno-omit-frame-pointer ............................. ............................. 1-43
1.21 -fropi, -fno-ropi .................................................... .................................................... 1-44
1.22 -fropi-lowering, -fno-ropi-lowering ............................................................................ 1-45
1.23 -frwpi, -fno-rwpi ................................................... ................................................... 1-46
1.24 -frwpi-lowering, -fno-rwpi-lowering .......................................................................... 1-47
1.25 -fshort-enums, -fno-short-enums ...................................... ...................................... 1-48
1.26 -fshort-wchar, -fno-short-wchar ................................................................................ 1-50
1.27 -fstrict-aliasing, -fno-strict-aliasing ..................................... ..................................... 1-51
1.28 -fvectorize, -fno-vectorize ........................................................................................ 1-52
1.29 -ftrapv ........................................................... ........................................................... 1-53
1.30 -fwrapv .......................................................... .......................................................... 1-54
1.31 -g, -gdwarf-2, -gdwarf-3, -gdwarf-4 .................................... .................................... 1-55
1.32 -I ............................................................... ............................................................... 1-56
1.33 -include .................................................................................................................... 1-57
1.34 -L .............................................................. .............................................................. 1-58
1.35 -l ............................................................... ............................................................... 1-59
1.36 -M, -MM ......................................................... ......................................................... 1-60
1.37 -MD, -MMD .............................................................................................................. 1-61
1.38 -MF .......................................................................................................................... 1-62
1.39 -MG .......................................................................................................................... 1-63
1.40 -MP .......................................................................................................................... 1-64
1.41 -MT .......................................................................................................................... 1-65
1.42 -march .......................................................... .......................................................... 1-66
1.43 -marm ...................................................................................................................... 1-68
1.44 -mbig-endian ............................................................................................................ 1-69
1.45 -mcmse .................................................................................................................... 1-70
1.46 -mcpu ........................................................... ........................................................... 1-72
1.47 -mexecute-only ........................................................................................................ 1-76
1.48 -mfloat-abi ................................................................................................................ 1-77
1.49 -mfpu ........................................................... ........................................................... 1-78
1.50 -mimplicit-it ....................................................... ....................................................... 1-80
1.51 -mlittle-endian .......................................................................................................... 1-81
1.52 -mno-neg-immediates .............................................................................................. 1-82
1.53 -munaligned-access, -mno-unaligned-access ............................ ............................ 1-84
1.54 -mthumb ......................................................... ......................................................... 1-85
1.55 -nostdlib ......................................................... ......................................................... 1-86
1.56 -nostdlibinc ....................................................... ....................................................... 1-87
1.57 -o .............................................................. .............................................................. 1-88
1.58 -O .............................................................. .............................................................. 1-89
1.59 -pedantic .................................................................................................................. 1-91
1.60 -pedantic-errors ................................................... ................................................... 1-92
1.61 -S .............................................................. .............................................................. 1-93
1.62 -save-temps ...................................................... ...................................................... 1-94
1.63 -std ............................................................. ............................................................. 1-95
1.64 --target .......................................................... .......................................................... 1-97
1.65 -U .............................................................. .............................................................. 1-98
1.66 -u .............................................................. .............................................................. 1-99
1.67 -v ............................................................................................................................ 1-100
1.68 --version ........................................................ ........................................................ 1-101
1.69 --version_number ................................................. ................................................. 1-102
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5
Non-Confidential
1.70 --vsn ........................................................... ........................................................... 1-103
1.71 -W .......................................................................................................................... 1-104
1.72 -Wl ............................................................ ............................................................ 1-105
1.73 -Xlinker ......................................................... ......................................................... 1-106
1.74 -x ............................................................................................................................ 1-107
1.75 -### ........................................................... ........................................................... 1-108
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6
Non-Confidential
3.32 __attribute__((packed)) variable attribute .............................................................. 3-156
3.33 __attribute__((section("name"))) variable attribute ................................................ 3-157
3.34 __attribute__((used)) variable attribute ................................ ................................ 3-158
3.35 __attribute__((unused)) variable attribute .............................. .............................. 3-159
3.36 __attribute__((weak)) variable attribute ................................ ................................ 3-160
3.37 __attribute__((weakref("target"))) variable attribute .............................................. 3-161
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7
Non-Confidential
7.12 Qualifiers ....................................................... ....................................................... 7-215
7.13 Preprocessing directives ........................................... ........................................... 7-216
7.14 Library functions .................................................................................................... 7-217
7.15 Architecture ..................................................... ..................................................... 7-222
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 8
Non-Confidential
List of Figures
ARM® Compiler armclang Reference Guide
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 9
Non-Confidential
List of Tables
ARM® Compiler armclang Reference Guide
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 10
Non-Confidential
Preface
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 11
Non-Confidential
Preface
About this book
Glossary
The ARM® Glossary is a list of terms used in ARM documentation, together with definitions for those
terms. The ARM Glossary does not contain terms that are industry standard unless the ARM meaning
differs from the generally accepted meaning.
See the ARM® Glossary for more information.
Typographic conventions
italic
Introduces special terminology, denotes cross-references, and citations.
bold
Highlights interface elements, such as menu names. Denotes signal names. Also used for terms
in descriptive lists, where appropriate.
monospace
Denotes text that you can enter at the keyboard, such as commands, file and program names,
and source code.
monospace
Denotes a permitted abbreviation for a command or option. You can enter the underlined text
instead of the full command or option name.
monospace italic
Denotes arguments to monospace text where the argument is to be replaced by a specific value.
monospace bold
Denotes language keywords when used outside example code.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 12
Non-Confidential
Preface
About this book
<and>
Encloses replaceable terms for assembler syntax where they appear in code or code fragments.
For example:
MRC p15, 0, <Rd>, <CRn>, <CRm>, <Opcode_2>
SMALL CAPITALS
Used in body text for a few terms that have specific technical meanings, that are defined in the
ARM® Glossary. For example, IMPLEMENTATION DEFINED, IMPLEMENTATION SPECIFIC, UNKNOWN, and
UNPREDICTABLE.
Feedback
Feedback on content
If you have comments on content then send an e-mail to [email protected]. Give:
• The title ARM Compiler armclang Reference Guide.
• The number ARM 100067_0608_00_en.
• If applicable, the page number(s) to which your comments refer.
• A concise explanation of your comments.
ARM also welcomes general suggestions for additions and improvements.
Note
ARM tests the PDF only in Adobe Acrobat and Acrobat Reader, and cannot guarantee the quality of the
represented document when used with any other PDF reader.
Other information
• ARM Developer.
• ARM Information Center.
• ARM Technical Support Knowledge Articles.
• Support and Maintenance.
• ARM Glossary.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 13
Non-Confidential
Chapter 1
armclang Command-line Options
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-14
Non-Confidential
1 armclang Command-line Options
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-15
Non-Confidential
1 armclang Command-line Options
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-16
Non-Confidential
1 armclang Command-line Options
1.1 Support level definitions
Product features
Product features are suitable for use in a production environment. The functionality is well-tested, and is
expected to be stable across feature and update releases.
• ARM endeavors to give advance notice of significant functionality changes to product features.
• If you have a support and maintenance contract, ARM provides full support for use of all product
features.
• ARM welcomes feedback on product features.
• Any issues with product features that ARM encounters or is made aware of are considered for fixing
in future versions of ARM Compiler.
In addition to fully supported product features, some product features are only alpha or beta quality.
Beta product features
Beta product features are implementation complete, but have not been sufficiently tested to be
regarded as suitable for use in production environments.
Beta product features are indicated with [BETA].
• ARM endeavors to document known limitations on beta product features.
• Beta product features are expected to eventually become product features in a future release
of ARM Compiler 6.
• ARM encourages the use of beta product features, and welcomes feedback on them.
• Any issues with beta product features that ARM encounters or is made aware of are
considered for fixing in future versions of ARM Compiler.
Alpha product features
Alpha product features are not implementation complete, and are subject to change in future
releases, therefore the stability level is lower than in beta product features.
Alpha product features are indicated with [ALPHA].
• ARM endeavors to document known limitations of alpha product features.
• ARM encourages the use of alpha product features, and welcomes feedback on them.
• Any issues with alpha product features that ARM encounters or is made aware of are
considered for fixing in future versions of ARM Compiler.
Community features
ARM Compiler 6 is built on LLVM technology and preserves the functionality of that technology where
possible. This means that there are additional features available in ARM Compiler that are not listed in
the documentation. These additional features are known as community features. For information on these
community features, see the documentation for the Clang/LLVM project.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-17
Non-Confidential
1 armclang Command-line Options
1.1 Support level definitions
Where community features are referenced in the documentation, they are indicated with
[COMMUNITY].
• ARM makes no claims about the quality level or the degree of functionality of these features, except
when explicitly stated in this documentation.
• Functionality might change significantly between feature releases.
• ARM makes no guarantees that community features will remain functional across update releases,
although changes are expected to be unlikely.
Some community features might become product features in the future, but ARM provides no roadmap
for this. ARM is interested in understanding your use of these features, and welcomes feedback on them.
ARM supports customers using these features on a best-effort basis, unless the features are unsupported.
ARM accepts defect reports on these features, but does not guarantee that these issues will be fixed in
future releases.
ARM C library
Assembly
Assembly Source
Source code
code Assembly
Assembly LLVM Project
libc++
armclang
armasm Source
Source code
code
headers
headers
LLVM Project
clang
Objects
Objects Objects
Objects Objects
Objects
armlink
Scatter/Steering/
Scatter/Steering/
Symdefs
Symdefs file
file
Image
Image
The dashed boxes are toolchain components, and any interaction between these components is an
integration boundary. Community features that span an integration boundary might have significant
limitations in functionality. The exception to this is if the interaction is codified in one of the
standards supported by ARM Compiler 6. See Application Binary Interface (ABI) for the ARM®
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-18
Non-Confidential
1 armclang Command-line Options
1.1 Support level definitions
Architecture. Community features that do not span integration boundaries are more likely to work as
expected.
• Features primarily used when targeting hosted environments such as Linux or BSD might have
significant limitations, or might not be applicable, when targeting bare-metal environments.
• The Clang implementations of compiler features, particularly those that have been present for a long
time in other toolchains, are likely to be mature. The functionality of new features, such as support
for new language features, is likely to be less mature and therefore more likely to have limited
functionality.
Unsupported features
With both the product and community feature categories, specific features and use-cases are known not
to function correctly, or are not intended for use with ARM Compiler 6.
Limitations of product features are stated in the documentation. ARM cannot provide an exhaustive list
of unsupported features or use-cases for community features. The known limitations on community
features are listed in Community features on page 1-17.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-19
Non-Confidential
1 armclang Command-line Options
1.2 Summary of armclang command-line options
Note
Assembly language source files are assembled using the armclang integrated assembler. C and C++
language source files, which can contain inline assembly code, are compiled using the armclang
compiler. Command-line options that are shown as Compilation only do not affect the integrated
assembler, but they can affect inline assembly code.
-fcommon, Generates common zero-initialized values for tentative definitions. Compilation only.
-fno-common
-fdata-sections, Enables or disables the generation of one ELF section for each variable Compilation only.
in the source file.
-fno-data-sections
-ffast-math, Enables or disables the use of aggressive floating-point optimizations. Compilation only.
-fno-fast-math
-ffunction-sections, Enables or disables the generation of one ELF section for each function Compilation only.
in the source file.
-fno-function-sections
@file Reads a list of command-line options from a file. Compilation and assembly.
-fldm-stm, Enable or disable the generation of LDM and STM instructions. Compilation only.
AArch32 only.
-fno-ldm-stm
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-20
Non-Confidential
1 armclang Command-line Options
1.2 Summary of armclang command-line options
-flto Enables link time optimization, and outputs bitcode wrapped in an ELF Compilation only.
file for link time optimization.
-fexceptions, Enables or disables the generation of code needed to support C++ Compilation only.
exceptions.
-fno-exceptions
-fomit-frame-pointer, Enables or disables the storage of stack frame pointers during function Compilation only.
calls.
-fno-omit-frame-pointer
-fropi-lowering, Enables or disables runtime static initialization when generating Read- Compilation only.
Only Position-Independent (ROPI) code.
-fno-ropi-lowering
-frwpi-lowering, Enables or disables runtime static initialization when generating Read- Compilation only.
Write Position-Independent (RWPI) code.
-fno-rwpi-lowering
-fshort-enums, Allows or disallows the compiler to set the size of an enumeration type Compilation only.
to the smallest data type that can hold all enumerator values.
-fno-short-enums
-fstrict-aliasing, Instructs the compiler to apply or not apply the strictest aliasing rules Compilation only.
available.
-fno-strict-aliasing
-fvectorize, Enables or disables the generation of Advanced SIMD vector Compilation only.
instructions directly from C or C++ code at optimization levels -O1 and
-fno-vectorize
higher.
-ftrapv Instructs the compiler to generate traps for signed arithmetic overflow Compilation only.
on addition, subtraction, and multiplication operations.
-fwrapv Instructs the compiler to assume that signed arithmetic overflow of Compilation only.
addition, subtraction, and multiplication, wraps using two's-complement
representation.
-g, Adds debug tables for source-level debugging. Compilation and assembly.
-gdwarf-2,
-gdwarf-3,
-gdwarf-4
-I Adds the specified directory to the list of places that are searched to find Compilation and assembly.
include files.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-21
Non-Confidential
1 armclang Command-line Options
1.2 Summary of armclang command-line options
-M, Produces a list of makefile dependency rules suitable for use by a make Compilation and assembly.
utility.
-MM
-MD, Compiles or assembles source files and produces a list of makefile Compilation and assembly.
dependency rules suitable for use by a make utility.
-MMD
-MF Specifies a filename for the makefile dependency rules produced by the Compilation only.
-M and -MD options.
-MG Prints dependency lines for header files even if the header files are Compilation only.
missing.
-MP Emits dummy dependency rules that work around make errors that are Compilation only.
generated if you remove header files without a corresponding update to
the makefile.
-MT Changes the target of the makefile dependency rule produced by Compilation and assembly.
dependency generating options.
-march Targets an architecture profile, generating generic code that runs on any Compilation and assembly.
processor of that architecture.
-marm Requests that the compiler targets the A32 or ARM instruction sets. Compilation only.
-mbig-endian Generates code suitable for an ARM processor using byte-invariant big- Compilation and assembly.
endian (BE-8) data.
-mcmse Enables the generation of code for the Secure state of the ARMv8-M Compilation only.
Security Extensions.
-mcpu Targets a specific processor, generating optimized code for that specific Compilation and assembly.
processor.
-mexecute-only Generates execute-only code, and prevents the compiler from Compilation only.
generating any data accesses to code sections.
-mfloat-abi Specifies whether to use hardware instructions or software library Compilation only.
functions for floating-point operations, and which registers are used to
pass floating-point parameters and return values.
-mfpu Specifies the target FPU architecture, that is the floating-point hardware Compilation and assembly.
available on the target.
-mimplicit-it Specifies the behavior of the integrated assembler if there are Compilation and assembly.
conditional instructions outside IT blocks.
-mlittle-endian Generates code suitable for an ARM processor using little-endian data. Compilation and assembly.
-mno-neg-immediates Disables the substitution of invalid instructions with valid equivalent Compilation and assembly.
instructions that use the logical inverse or negative of the specified
immediate value.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-22
Non-Confidential
1 armclang Command-line Options
1.2 Summary of armclang command-line options
-munaligned-access, Enables or disables unaligned accesses to data on ARM processors. Compilation only.
-mno-unaligned-access
-mthumb Requests that the compiler targets the T32 or Thumb instruction sets. Compilation only.
-o Specifies the name of the output file. Compilation and assembly.
-O Specifies the level of optimization to use when compiling source files. Compilation only.
-S Outputs the disassembly of the machine code generated by the compiler. Compilation only.
-save-temps Instructs the compiler to generate intermediate assembly files from the Compilation only.
specified C/C++ file.
-std Specifies the language standard to compile for. Compilation only.
--target Generate code for the specified target triple. Compilation and assembly.
-U Removes any initial definition of the specified preprocessor macro. Compilation only.
-u Prevents the removal of a specified symbol if it is undefined. Compilation and assembly.
-v Displays the commands that invoke the compiler and linker, and Compilation and assembly.
executes those commands.
--version Displays the same information as --vsn. Compilation and assembly.
--version_number Displays the version of armclang you are using. Compilation and assembly.
--vsn Displays the version information and the license details. Compilation and assembly.
-W Controls diagnostics. Compilation only.
-Wl Specifies linker command-line options to pass to the linker when a link Compilation only.
step is being performed after compilation.
-Xlinker Specifies linker command-line options to pass to the linker when a link Compilation only.
step is being performed after compilation.
-x Specifies the language of source files. Compilation and assembly.
-### Displays the commands that invoke the compiler and sub-tools, such as Compilation and assembly.
armlink, without executing those commands.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-23
Non-Confidential
1 armclang Command-line Options
1.3 -C
1.3 -C
Keep comments in the preprocessed output.
By default, comments are stripped out. Use the -C option to keep comments in the preprocessed output.
With the -C option, all comments are passed through to the output file, except for comments in processed
directives which are deleted along with the directive.
Usage
You must specify the -E option when you use the -C option.
Using the -C option does not implicitly select the -E option. If you do not specify the -E option, the
compiler reports:
warning: argument unused during compilation: '-C' [-Wunused-command-line-argument]
The -C option can also be used when preprocessing assembly files, using:
• -xassembler-with-cpp, or a file that has an upper-case extension, with the armclang integrated
assembler.
• --cpreproc and --cpreproc_opts with the legacy assembler, armasm.
Example
Here is an example program, foo.c, which contains some comments:
#define HIGH 1 // Comment on same line as directive
#define LOW 0
#define LEVEL 10
// #define THIS 99
// Comment A
/* Comment B */
Use armclang to preprocess this example code with the -C option to retain comments. The -E option
executes the preprocessor step only.
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -C -E foo.c
// Comment A
/* Comment B */
int Signal (int value)
{
if (value>LEVEL) return 1; // Comment C
return 0 + THIS;
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-24
Non-Confidential
1 armclang Command-line Options
1.3 -C
Related references
1.6 -E on page 1-28.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-25
Non-Confidential
1 armclang Command-line Options
1.4 -c
1.4 -c
Instructs the compiler to perform the compilation step, but not the link step.
Usage
ARM recommends using the -c option in projects with more than one source file.
The compiler creates one object file for each source file, with a .o file extension replacing the file
extension on the input source file. For example, the following creates object files test1.o, test2.o, and
test3.o:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -c test1.c test2.c test3.c
Note
If you specify multiple source files with the -c option, the -o option results in an error. For example:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -c test1.c test2.c -o test.o
armclang: error: cannot specify -o when generating multiple output files
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-26
Non-Confidential
1 armclang Command-line Options
1.5 -D
1.5 -D
Defines a macro name.
Syntax
-Dname[(parm-list)][=def]
Where:
name
Is the name of the macro to be defined.
parm-list
Is an optional list of comma-separated macro parameters. By appending a macro parameter list
to the macro name, you can define function-style macros.
The parameter list must be enclosed in parentheses. When specifying multiple parameters, do
not include spaces between commas and parameter names in the list.
Note
Parentheses might require escaping on UNIX systems.
=def
Is an optional macro definition.
If =def is omitted, the compiler defines name as the value 1.
To include characters recognized as tokens on the command line, enclose the macro definition in
double quotes.
Usage
Specifying -Dname has the same effect as placing the text #define name at the head of each source file.
Example
Specifying this option:
-DMAX(X,Y)="((X > Y) ? X : Y)"
Related references
1.33 -include on page 1-57.
1.65 -U on page 1-98.
1.74 -x on page 1-107.
Related information
Preprocessing assembly code.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-27
Non-Confidential
1 armclang Command-line Options
1.6 -E
1.6 -E
Executes the preprocessor step only.
By default, output from the preprocessor is sent to the standard output stream and can be redirected to a
file using standard UNIX and MS-DOS notation.
You can also use the -o option to specify a file for the preprocessed output.
By default, comments are stripped from the output. Use the -C option to keep comments in the
preprocessed output.
Examples
Use -E -dD to generate interleaved macro definitions and preprocessor output:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -E -dD source.c > raw.c
Use -E -dM to list all the macros that are defined at the end of the translation unit, including the
predefined macros:
armclang --target=arm-arm-none-eabi -mcpu=cortex-m3 -E -dM source.c
Related references
1.3 -C on page 1-24.
1.64 --target on page 1-97.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-28
Non-Confidential
1 armclang Command-line Options
1.7 -e
1.7 -e
Specifies the unique initial entry point of the image.
If linking, armclang translates this option to --entry and passes it to armlink. If the link step is not
being performed, this option is ignored.
See the ARM® Compiler toolchain Linker Reference for information about the --entry linker options.
Related information
armlink User Guide.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-29
Non-Confidential
1 armclang Command-line Options
1.8 -fbare-metal-pie
1.8 -fbare-metal-pie
Generates position independent code.
This option causes the compiler to invoke armlink with the –-bare_metal_pie option when performing
the link step.
Note
• This option is unsupported for AArch64 state.
• Bare-metal PIE support is deprecated in this release.
Related references
1.21 -fropi, -fno-ropi on page 1-44.
1.23 -frwpi, -fno-rwpi on page 1-46.
Related information
Bare-metal Position Independent Executables.
--fpic armlink option.
--pie armlink option.
--bare_metal_pie armlink option.
--ref_pre_init armlink option.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-30
Non-Confidential
1 armclang Command-line Options
1.9 -fbracket-depth=N
1.9 -fbracket-depth=N
Sets the limit for nested parentheses, brackets, and braces to N in blocks, declarators, expressions, and
struct or union declarations.
Syntax
-fbracket-depth=N
Usage
You can increase the depth limit N.
Default
The default depth limit is 256.
Related references
7.3 Translation limits on page 7-203.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-31
Non-Confidential
1 armclang Command-line Options
1.10 -fcommon, -fno-common
Default
The default is -fno-common.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-32
Non-Confidential
1 armclang Command-line Options
1.11 -fdata-sections, -fno-data-sections
Note
If you want to place specific data items or structures in separate sections, mark them individually with
__attribute__((section("name"))).
Example
volatile int a = 9;
volatile int c = 10;
volatile int d = 11;
int main(void){
static volatile int b = 2;
return a == b;
}
...
Symbol table .symtab (17 symbols, 11 local)
If you compare the two Sec columns, you can see that when -fdata-sections is used, the variables are
put into different sections. When -fno-data-sections is used, all the variables are put into the same
section.
Related references
1.14 -ffunction-sections, -fno-function-sections on page 1-37.
3.33 __attribute__((section("name"))) variable attribute on page 3-157.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-33
Non-Confidential
1 armclang Command-line Options
1.12 -ffast-math, -fno-fast-math
-ffast-math results in behavior that is not fully compliant with the ISO C or C++ standard. However,
numerically robust floating-point programs are expected to behave correctly. ARM recommends that you
use the alias option -ffp-mode=fast instead of -ffast-math.
Using -fno-fast-math disables aggressive floating-point optimizations. It also ensures that the floating-
point code that the compiler generates is compliant with the IEEE Standard for Floating-Point Arithmetic
(IEEE 754). ARM recommends that you use the alias option -ffp-mode=full instead of -fno-fast-
math.
Note
ARM Compiler 6 uses neither -ffast-math nor -fno-fast-math by default. For the default behavior,
specify -ffp-mode=std.
These options control which floating-point library the compiler uses. For more information, see the
library variants in ARM C and C++ Libraries and Floating-Point Support User Guide.
Related references
1.13 -ffp-mode on page 1-35.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-34
Non-Confidential
1 armclang Command-line Options
1.13 -ffp-mode
1.13 -ffp-mode
-ffp-mode specifies floating-point standard conformance. This controls which floating-point
optimizations the compiler can perform, and also influences library selection.
Syntax
-ffp-mode=model
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-35
Non-Confidential
1 armclang Command-line Options
1.13 -ffp-mode
Default
The default is -ffp-mode=std.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-36
Non-Confidential
1 armclang Command-line Options
1.14 -ffunction-sections, -fno-function-sections
-ffunction-sections is set by default. The output section for each function has the same name as the
function that generates the section, but with a .text. prefix. To disable this, use -fno-function-
sections.
Note
If you want to place specific data items or structures in separate sections, mark them individually with
__attribute__((section("name"))).
Restrictions
-ffunction-sections reduces the potential for sharing addresses, data, and string literals between
functions. Consequently, it might increase code size slightly for some functions.
Example
int function1(int x)
{
return x+1;
}
int function2(int x)
{
return x+2;
}
...
.section .text.function1,"ax",%progbits
.globl function1
.p2align 2
.type function1,%function
function1: @ @function1
.fnstart
@ BB#0:
add r0, r0, #1
bx lr
.Lfunc_end0:
.size function1, .Lfunc_end0-function1
.cantunwind
.fnend
.section .text.function2,"ax",%progbits
.globl function2
.p2align 2
.type function2,%function
function2: @ @function2
.fnstart
@ BB#0:
add r0, r0, #2
bx lr
.Lfunc_end1:
.size function2, .Lfunc_end1-function2
.cantunwind
.fnend
...
Related references
3.17 __attribute__((section("name"))) function attribute on page 3-140.
1.11 -fdata-sections, -fno-data-sections on page 1-33.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-37
Non-Confidential
1 armclang Command-line Options
1.15 @file
1.15 @file
Reads a list of armclang options from a file.
Syntax
@file
Where file is the name of a file containing armclang options to include on the command line.
Usage
The options in the specified file are inserted in place of the @file option.
Use whitespace or new lines to separate options in the file. Enclose strings in single or double quotes to
treat them as a single word.
You can specify multiple @file options on the command line to include options from multiple files. Files
can contain more @file options.
If any @file option specifies a non-existent file or circular dependency, armclang exits with an error.
Note
To use Windows-style file paths on the command-line, you must escape the backslashes. For example:
-I"..\\my libs\\".
Example
Consider a file options.txt with the following content:
-I"../my libs/"
--target=aarch64-arm-none-eabi -mcpu=cortex-a57
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-38
Non-Confidential
1 armclang Command-line Options
1.16 -fldm-stm, -fno-ldm-stm
Usage
The -fno-ldm-stm option can reduce interrupt latency on ARM systems that:
• Do not have a cache or a write buffer.
• Use zero-wait-state, 32-bit memory.
Note
Using -fno-ldm-stm might slightly increase code size and decrease performance.
Restrictions
Existing LDM and STM instructions (for example, in assembly code you are assembling with armclang) are
not removed.
Default
The default is -fldm-stm. That is, by default armclang can generate LDM and STM instructions.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-39
Non-Confidential
1 armclang Command-line Options
1.17 -fno-inline-functions
1.17 -fno-inline-functions
Disabling the inlining of functions can help to improve the debug experience.
The compiler attempts to automatically inline functions at optimization levels -O2 and -O3. When these
levels are used with -fno-inline-functions, automatic inlining is disabled.
When optimization levels -O0 and -O1 are used with -fno-inline-functions, no automatic inlining is
attempted, and only functions that are tagged with __attribute__((always_inline)) are inlined.
Related concepts
6.3 Inline functions on page 6-194.
Related references
1.58 -O on page 1-89.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-40
Non-Confidential
1 armclang Command-line Options
1.18 -flto
1.18 -flto
Enables link time optimization, and outputs bitcode wrapped in an ELF file for link time optimization.
The primary use for files containing bitcode is for link time optimization. See Optimizing across modules
with link time optimization in the Software Development Guide for more information about link time
optimization.
Usage
The compiler creates one file for each source file, with a .o file extension replacing the file extension on
the input source file.
The -flto option passes the --lto option to armlink to enable link time optimization, unless the -c
option is specified.
-flto is automatically enabled when you specify the armclang -Omax option.
Note
Object files produced with -flto contain bitcode, which cannot be disassembled into meaningful
disassembly using the -S option or the fromelf tool.
Caution
Object files generated using the -flto option are not suitable for creating static libraries, or ROPI or
RWPI images.
Caution
Link Time Optimization performs aggressive optimizations. Sometimes this can result in large chunks of
code being removed.
Note
Link Time Optimization does not honor the armclang -mexecute-only option. If you use the armclang
-flto or -Omax options, then the compiler cannot generate execute-only code.
Related references
1.4 -c on page 1-26.
Related information
Optimizing across modules with link time optimization.
Restrictions with link time optimization.
--lto armlink option.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-41
Non-Confidential
1 armclang Command-line Options
1.19 -fexceptions, -fno-exceptions
Default
The default is -fexceptions for C++ sources. The default is -fno-exceptions for C sources.
Usage
Compiling with -fno-exceptions disables exceptions support and uses the variant of C++ libraries
without exceptions. Use of try, catch, or throw results in an error message.
Linking objects that have been compiled with -fno-exceptions automatically selects the libraries
without exceptions. You can use the linker option --no_exceptions to diagnose whether the objects
being linked contain exceptions.
Note
If an exception propagates into a function that has been compiled without exceptions support, then the
program terminates.
Related information
Standard C++ library implementation definition.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-42
Non-Confidential
1 armclang Command-line Options
1.20 -fomit-frame-pointer, -fno-omit-frame-pointer
The -fomit-frame-pointer option instructs the compiler to not store stack frame pointers if the
function does not need it. You can use this option to reduce the code image size.
The -fno-omit-frame-pointer option instructs the compiler to store the stack frame pointer in a
register. In AArch32, the frame pointer is stored in register R11 for ARM code or register R7 for Thumb
code. In AArch64, the frame pointer is stored in register X29. The register that is used as a frame pointer
is not available for use as a general-purpose register. It is available as a general-purpose register if you
compile with -fomit-frame-pointer.
Default
The default is -fomit-frame-pointer.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-43
Non-Confidential
1 armclang Command-line Options
1.21 -fropi, -fno-ropi
Usage
When generating ROPI code, the compiler:
• Addresses read-only code and data PC-relative.
• Sets the Position Independent (PI) attribute on read-only output sections.
Note
• This option is independent from -frwpi, meaning that these two options can be used individually or
together.
• When using -fropi, -fropi-lowering is automatically enabled.
Default
The default is -fno-ropi.
Restrictions
The following restrictions apply:
• This option is not supported in AArch64 mode.
• This option cannot be used with C++ code.
• This option is not compatible with -fpic, -fpie, or -fbare-metal-pie options.
Related references
1.23 -frwpi, -fno-rwpi on page 1-46.
1.24 -frwpi-lowering, -fno-rwpi-lowering on page 1-47.
1.22 -fropi-lowering, -fno-ropi-lowering on page 1-45.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-44
Non-Confidential
1 armclang Command-line Options
1.22 -fropi-lowering, -fno-ropi-lowering
Default
The default is -fno-ropi-lowering. If -fropi is used, then the default is -fropi-lowering. If -frwpi
is used without -fropi, then the default is -fropi-lowering.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-45
Non-Confidential
1 armclang Command-line Options
1.23 -frwpi, -fno-rwpi
Usage
When generating RWPI code, the compiler:
• Addresses the writable data using offsets from the static base register sb. This means that:
— The base address of the RW data region can be fixed at runtime.
— Data can have multiple instances.
— Data can be, but does not have to be, position-independent.
• Sets the PI attribute on read/write output sections.
Note
• This option is independent from -fropi, meaning that these two options can be used individually or
together.
• When using -frwpi, -frwpi-lowering and -fropi-lowering are automatically enabled.
Restrictions
The following restrictions apply:
• This option is not supported in AArch64 mode.
• This option is not compatible with -fpic, -fpie, or -fbare-metal-pie options.
Default
The default is -fno-rwpi.
Related references
1.21 -fropi, -fno-ropi on page 1-44.
1.22 -fropi-lowering, -fno-ropi-lowering on page 1-45.
1.24 -frwpi-lowering, -fno-rwpi-lowering on page 1-47.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-46
Non-Confidential
1 armclang Command-line Options
1.24 -frwpi-lowering, -fno-rwpi-lowering
Default
The default is -fno-rwpi-lowering. If -frwpi is used, then the default is -frwpi-lowering.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-47
Non-Confidential
1 armclang Command-line Options
1.25 -fshort-enums, -fno-short-enums
Note
The -fshort-enums option is not supported for AArch64. The Procedure Call Standard for the ARM®
64-bit Architecture states that the size of enumeration types must be at least 32 bits.
Default
The default is -fno-short-enums. That is, the size of an enumeration type is at least 32 bits regardless
of the size of the enumerator values.
Example
This example shows the size of four different enumeration types: 8-bit, 16-bit, 32-bit, and 64-bit integers.
#include <stdio.h>
int main(void)
{
printf("size of int8Enum is %zd\n", sizeof (enum int8Enum));
printf("size of int16Enum is %zd\n", sizeof (enum int16Enum));
printf("size of int32Enum is %zd\n", sizeof (enum int32Enum));
printf("size of int64Enum is %zd\n", sizeof (enum int64Enum));
}
When compiled without the -fshort-enums option, all enumeration types are 32 bits (4 bytes) except for
int64Enum which requires 64 bits (8 bytes):
size of int8Enum is 4
size of int16Enum is 4
size of int32Enum is 4
size of int64Enum is 8
When compiled with the -fshort-enums option, each enumeration type has the smallest size possible to
hold the largest enumerator value:
armclang -fshort-enums --target=arm-arm-none-eabi -march=armv8-a enum_test.cpp
size of int8Enum is 1
size of int16Enum is 2
size of int32Enum is 4
size of int64Enum is 8
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-48
Non-Confidential
1 armclang Command-line Options
1.25 -fshort-enums, -fno-short-enums
Note
ISO C restricts enumerator values to the range of int. By default armclang does not issue warnings
about enumerator values that are too large, but with -Wpedantic a warning is displayed.
Related information
Procedure Call Standard for the ARM 64-bit Architecture (AArch64).
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-49
Non-Confidential
1 armclang Command-line Options
1.26 -fshort-wchar, -fno-short-wchar
The -fshort-wchar option can improve memory usage, but might reduce performance because narrow
memory accesses can be less efficient than full register-width accesses.
Note
All linked objects must use the same wchar_t size, including libraries. It is not possible to link an object
file compiled with -fshort-wchar, with another object file that is compiled without -fshort-wchar.
Default
The default is -fno-short-wchar. That is, the default size of wchar_t is 4 bytes.
Example
This example shows the size of the wchar_t type:
#include <stdio.h>
#include <wchar.h>
int main(void)
{
printf("size of wchar_t is %zd\n", sizeof (wchar_t));
return 0;
}
When compiled without the -fshort-wchar option, the size of wchar_t is 4 bytes:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 wchar_test.c
size of wchar_t is 4
When compiled with the -fshort-wchar option, the size of wchar_t is 2 bytes:
armclang -fshort-wchar --target=aarch64-arm-none-eabi -mcpu=cortex-a53 wchar_test.c
size of wchar_t is 2
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-50
Non-Confidential
1 armclang Command-line Options
1.27 -fstrict-aliasing, -fno-strict-aliasing
Usage
-fstrict-aliasing is implicitly enabled at -O1 or higher. It is disabled at -O0, or when no optimization
level is specified.
When optimizing at -O1 or higher, this option can be disabled with -fno-strict-aliasing.
Note
Specifying -fstrict-aliasing on the command-line has no effect, since it is either implicitly enabled,
or automatically disabled, depending on the optimization level that is used.
Examples
In the following example, -fstrict-aliasing is enabled:
armclang --target=aarch64-arm-none-eabi -O2 -c hello.c
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-51
Non-Confidential
1 armclang Command-line Options
1.28 -fvectorize, -fno-vectorize
Default
The default depends on the optimization level in use.
At optimization level -O0 (the default optimization level), armclang never performs automatic
vectorization. The -fvectorize and -fno-vectorize options are ignored.
At optimization level -O1, the default is -fno-vectorize. Use -fvectorize to enable automatic
vectorization. When using -fvectorize with -O1, vectorization might be inhibited in the absence of
other optimizations which might be present at -O2 or higher.
At optimization level -O2 and above, the default is -fvectorize. Use -fno-vectorize to disable
automatic vectorization.
Using -fno-vectorize does not necessarily prevent the compiler from emitting Advanced SIMD
instructions. The compiler or linker might still introduce Advanced SIMD instructions, such as when
linking libraries that contain these instructions.
Examples
This example enables automatic vectorization with optimization level -O1:
armclang --target=arm-arm-none-eabi -march=armv8-a -fvectorize -O1 -c file.c
To prevent the compiler from emitting Advanced SIMD instructions for AArch64 targets, specify
+nosimd using -march or -mcpu. For example:
To prevent the compiler from emitting Advanced SIMD instructions for AArch32 targets, set the option -
mfpu to the correct value that does not include Advanced SIMD, for example fp-armv8:
Related references
1.4 -c on page 1-26.
1.58 -O on page 1-89.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-52
Non-Confidential
1 armclang Command-line Options
1.29 -ftrapv
1.29 -ftrapv
Instructs the compiler to generate traps for signed arithmetic overflow on addition, subtraction, and
multiplication operations.
Usage
Where an overflow is detected, an undefined instruction is inserted into the assembly code. In order for
the overflow to get caught, an undefined instruction handler must be provided.
Note
When both -fwrapv and -ftrapv are used in a single command, the furthest-right option overrides the
other.
For example, here -ftrapv overrides -fwrapv:
armclang --target=aarch64-arm-none-eabi -fwrapv -c -ftrapv hello.c
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-53
Non-Confidential
1 armclang Command-line Options
1.30 -fwrapv
1.30 -fwrapv
Instructs the compiler to assume that signed arithmetic overflow of addition, subtraction, and
multiplication, wraps using two's-complement representation.
Note
When both -fwrapv and -ftrapv are used in a single command, the furthest-right option overrides the
other.
For example, here -fwrapv overrides -ftrapv:
armclang --target=aarch64-arm-none-eabi -ftrapv -c -fwrapv hello.c
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-54
Non-Confidential
1 armclang Command-line Options
1.31 -g, -gdwarf-2, -gdwarf-3, -gdwarf-4
Syntax
-g
-gdwarf-version
Where:
version
is the DWARF format to produce. Valid values are 2, 3, and 4.
The -g option is a synonym for -gdwarf-4.
Usage
The compiler produces debug information that is compatible with the specified DWARF standard.
Use a compatible debugger to load, run, and debug images. For example, ARM DS-5 Debugger is
compatible with DWARF 4. Compile with the -g or -gdwarf-4 options to debug with ARM DS-5
Debugger.
Legacy and third-party tools might not support DWARF 4 debug information. In this case you can
specify the level of DWARF conformance required using the -gdwarf-2 or -gdwarf-3 options.
Because the DWARF 4 specification supports language features that are not available in earlier versions
of DWARF, the -gdwarf-2 and -gdwarf-3 options should only be used for backwards compatibility.
Default
By default, armclang does not produce debug information. When using -g, the default level is DWARF
4.
Examples
If you specify multiple options, the last option specified takes precedence. For example:
• -gdwarf-3 -gdwarf-2 produces DWARF 2 debug, because -gdwarf-2 overrides -gdwarf-3.
• -g -gdwarf-2 produces DWARF 2 debug, because -gdwarf-2 overrides the default DWARF level
implied by -g.
• -gdwarf-2 -g produces DWARF 4 debug, because -g (a synonym for -gdwarf-4) overrides -
gdwarf-2.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-55
Non-Confidential
1 armclang Command-line Options
1.32 -I
1.32 -I
Adds the specified directory to the list of places that are searched to find include files.
If you specify more than one directory, the directories are searched in the same order as the -I options
specifying them.
Syntax
-Idir
Where:
dir
is a directory to search for included files.
Use multiple -I options to specify multiple search directories.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-56
Non-Confidential
1 armclang Command-line Options
1.33 -include
1.33 -include
Includes the source code of the specified file at the beginning of the compilation.
Syntax
-include filename
Where filename is the name of the file whose source code is to be included.
Note
Any -D, -I, and -U options on the command line are always processed before -include filename.
Related references
1.5 -D on page 1-27.
1.32 -I on page 1-56.
1.65 -U on page 1-98.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-57
Non-Confidential
1 armclang Command-line Options
1.34 -L
1.34 -L
Specifies a list of paths that the linker searches for user libraries.
Syntax
-L dir[,dir,...]
Where:
dir[,dir,...]
is a comma-separated list of directories to be searched for user libraries.
At least one directory must be specified.
When specifying multiple directories, do not include spaces between commas and directory
names in the list.
armclang translates this option to --userlibpath and passes it to armlink.
See the ARM® Compiler armlink User Guide for information about the --userlibpath linker option.
Note
The -L option has no effect when used with the -c option, that is when not linking.
Related information
armlink User Guide.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-58
Non-Confidential
1 armclang Command-line Options
1.35 -l
1.35 -l
Add the specified library to the list of searched libraries.
Syntax
-l name
See the ARM® Compiler toolchain Linker Reference for information about the --library linker option.
Note
The -l option has no effect when used with the -c option, that is when not linking.
Related information
armlink User Guide.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-59
Non-Confidential
1 armclang Command-line Options
1.36 -M, -MM
Note
To compile or assemble the source files and produce makefile dependency rules, use the -MD or -MMD
option instead of the -M or -MM option respectively.
Example
You can redirect output to a file using standard UNIX and MS-DOS notation, the -o option, or the -MF
option. For example:
armclang --target=arm-arm-none-eabi -march=armv8-a -M source.c > deps.mk
armclang --target=arm-arm-none-eabi -march=armv8-a -M source.c -o deps.mk
armclang --target=arm-arm-none-eabi -march=armv8-a -M source.c -MF deps.mk
Related references
1.57 -o on page 1-88.
1.37 -MD, -MMD on page 1-61.
1.38 -MF on page 1-62.
1.41 -MT on page 1-65.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-60
Non-Confidential
1 armclang Command-line Options
1.37 -MD, -MMD
Example
The following example creates makefile dependency lists test1.d and test2.d and compiles the source
files to an image with the default name, a.out:
armclang --target=arm-arm-none-eabi -march=armv8-a -MD test1.c test2.c
Related references
1.36 -M, -MM on page 1-60.
1.38 -MF on page 1-62.
1.41 -MT on page 1-65.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-61
Non-Confidential
1 armclang Command-line Options
1.38 -MF
1.38 -MF
Specifies a filename for the makefile dependency rules produced by the -M and -MD options.
Syntax
-MF filename
Where:
filename
Specifies the filename for the makefile dependency rules.
Note
The -MF option only has an effect when used in conjunction with one of the -M, -MM, -MD, or -MMD
options.
The -MF option overrides the default behavior of sending dependency generation output to the standard
output stream, and sends output to the specified filename instead.
armclang -MD sends output to a file with the same name as the source file by default, but with a .d
suffix. The -MF option sends output to the specified filename instead. Only use a single source file with
armclang -MD -MF.
Examples
This example sends makefile dependency rules to standard output, without compiling the source:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M source.c
This example saves makefile dependency rules to deps.mk, without compiling the source:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M source.c -MF deps.mk
This example compiles the source and saves makefile dependency rules to source.d (using the default
file naming rules):
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -MD source.c
This example compiles the source and saves makefile dependency rules to deps.mk:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -MD source.c -MF deps.mk
Related references
1.36 -M, -MM on page 1-60.
1.37 -MD, -MMD on page 1-61.
1.41 -MT on page 1-65.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-62
Non-Confidential
1 armclang Command-line Options
1.39 -MG
1.39 -MG
Prints dependency lines for header files even if the header files are missing.
Warning and error messages on missing header files are suppressed, and compilation continues.
Note
The -MG option only has an effect when used with one of the following options: -M or -MM.
Example
source.c contains a reference to a missing header file header.h:
#include <stdio.h>
#include "header.h"
int main(void){
puts("Hello world\n");
return 0;
}
This first example is compiled without the -MG option, and results in an error:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M source.c
This second example is compiled with the -MG option, and the error is suppressed:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M -MG source.c
source.o: source.c \
/include/stdio.h \
header.h
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-63
Non-Confidential
1 armclang Command-line Options
1.40 -MP
1.40 -MP
Emits dummy dependency rules.
These rules work around make errors that are generated if you remove header files without a
corresponding update to the makefile.
Note
The -MP option only has an effect when used in conjunction with the -M, -MD, -MM, or -MMD options.
Examples
This example sends dependency rules to standard output, without compiling the source.
source.c includes a header file:
#include <stdio.h>
int main(void){
puts("Hello world\n");
return 0;
}
This first example is compiled without the -MP option, and results in a dependency rule for source.o:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M source.c
source.o: source.c \
/include/stdio.h
This second example is compiled with the -MP option, and results in a dependency rule for source.o and
a dummy rule for the header file:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M -MP source.c
source.o: source.c \
/include/stdio.h
/include/stdio.h:
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-64
Non-Confidential
1 armclang Command-line Options
1.41 -MT
1.41 -MT
Changes the target of the makefile dependency rule produced by dependency generating options.
Note
The -MT option only has an effect when used in conjunction with either the -M, -MM, -MD, or -MMD options.
By default, armclang -M creates makefile dependencies rules based on the source filename:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M test.c
test.o: test.c header.h
The -MT option renames the target of the makefile dependency rule:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M test.c -MT foo
foo: test.c header.h
The compiler executes only the preprocessor step of the compilation. By default, output is on the
standard output stream.
If you specify multiple source files, the -MT option renames the target of all dependency rules:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M test1.c test2.c -MT foo
foo: test1.c header.h
foo: test2.c header.h
Specifying multiple -MT options creates multiple targets for each rule:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 -M test1.c test2.c -MT foo -MT bar
foo bar: test1.c header.h
foo bar: test2.c header.h
Related references
1.36 -M, -MM on page 1-60.
1.37 -MD, -MMD on page 1-61.
1.38 -MF on page 1-62.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-65
Non-Confidential
1 armclang Command-line Options
1.42 -march
1.42 -march
Targets an architecture profile, generating generic code that runs on any processor of that architecture.
Syntax
To specify a target architecture, use:
-march=name
Where:
name
Specifies the architecture.
To view a list of all the supported architectures, use:
-march=list
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-66
Non-Confidential
1 armclang Command-line Options
1.42 -march
Note
There are no software floating-point libraries for AArch64 targets. At link time armlink links against
AArch64 library code that can use floating-point and SIMD instructions and registers. This still applies if
you compile the source with -march=<name>+nofp+nosimd to prevent the compiler from using floating-
point and SIMD instructions and registers.
To prevent the use of any floating-point instruction or register, either re-implement the library functions
or create your own library that does not use floating-point instructions or registers.
Default
For AArch64 targets (--target=aarch64-arm-none-eabi), unless you target a particular processor
using -mcpu, the compiler defaults to -march=armv8-a, generating generic code for ARMv8-A in
AArch64 state.
For AArch32 targets (--target=arm-arm-none-eabi), there is no default. You must specify either -
march (to target an architecture) or -mcpu (to target a processor).
Related references
1.46 -mcpu on page 1-72.
1.43 -marm on page 1-68.
1.54 -mthumb on page 1-85.
1.64 --target on page 1-97.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-67
Non-Confidential
1 armclang Command-line Options
1.43 -marm
1.43 -marm
Requests that the compiler targets the A32 or ARM instruction sets.
Most ARMv7-A (and earlier) processors support two instruction sets: the ARM instruction set, and the
Thumb instruction set. ARMv8-A AArch32 continues to support these two instruction sets, but they are
renamed as A32 and T32 respectively. ARMv8-A additionally introduces the A64 instruction set, used in
the AArch64 execution state.
Different architectures support different instruction sets:
• ARMv8-A processors in AArch64 state execute A64 instructions.
• ARMv8-A processors in AArch32 state, as well as ARMv7 and earlier A- and R- profile processors
execute A32 (formerly ARM) and T32 (formerly Thumb) instructions.
• M-profile processors execute T32 (formerly Thumb) instructions.
The -marm option targets the A32 (formerly ARM) instruction set.
Note
This option is only valid for targets that support the A32 or ARM instruction sets. For example, the -
marm option is not valid with AArch64 targets. The compiler ignores the -marm option and generates a
warning with AArch64 targets.
Default
The default for all targets that support ARM or A32 instructions is -marm.
Related references
1.54 -mthumb on page 1-85.
1.64 --target on page 1-97.
1.46 -mcpu on page 1-72.
Related information
Specifying a target architecture, processor, and instruction set.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-68
Non-Confidential
1 armclang Command-line Options
1.44 -mbig-endian
1.44 -mbig-endian
Generates code suitable for an ARM processor using byte-invariant big-endian (BE-8) data.
Default
The default is -mlittle-endian.
Related references
1.51 -mlittle-endian on page 1-81.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-69
Non-Confidential
1 armclang Command-line Options
1.45 -mcmse
1.45 -mcmse
Enables the generation of code for the Secure state of the ARMv8-M Security Extensions. This option is
required when creating a Secure image.
Note
ARMv8-M Security Extensions are not supported when building Read-Only Position-Independent
(ROPI) and Read-Write Position-Independent (RWPI) images.
Usage
Specifying -mcmse targets the Secure state of the ARMv8-M Security Extensions. The following are
available:
• The Test Target, TT, instruction.
• TT instruction intrinsics.
• Non-secure function pointer intrinsics.
• __attribute__((cmse_nonsecure_call)) and __attribute__((cmse_nonsecure_entry))
function attributes.
Note
• The value of the __ARM_FEATURE_CMSE predefined macro indicates what ARMv8-M Security
Extension features are supported.
• Compile Secure code with the maximum capabilities for the target. For example, if you compile with
no FPU then the Secure functions do not clear floating-point registers when returning from functions
declared as __attribute__((cmse_nonsecure_entry)). Therefore, the functions could potentially
leak sensitive data.
• Structs with undefined bits caused by padding and half float are currently unsupported as arguments
and return values for Secure functions. Using such structs might leak sensitive information. Structs
that are large enough to be passed by pointer are also unsupported and produce an error.
• The following cases are not supported when compiling with -mcmse and give an error:
— Variadic entry functions.
— Entry functions with arguments that do not fit in registers, because there are either many
arguments or the arguments have large values.
— Non-secure function calls with arguments that do not fit in registers, because there are either
many arguments or the arguments have large values.
Example
This example shows how to create a Secure image using an input import library, oldimportlib.o, and a
scatter file, secure.scat:
armclang --target=arm-arm-none-eabi -march=armv8m.main -mcmse secure.c -o secure.o
armlink secure.o -o secure.axf --import-cmse-lib-out importlib.o --import-cmse-lib-in
oldimportlib.o --scatter secure.scat
armlink also generates the Secure code import library, importlib.o that is required for a Non-secure
image to call the Secure image.
Related references
1.42 -march on page 1-66.
1.49 -mfpu on page 1-78.
1.64 --target on page 1-97.
3.3 __attribute__((cmse_nonsecure_call)) function attribute on page 3-126.
3.4 __attribute__((cmse_nonsecure_entry)) function attribute on page 3-127.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-70
Non-Confidential
1 armclang Command-line Options
1.45 -mcmse
Related information
Building Secure and Non-secure Images Using ARMv8-M Security Extensions.
TT, TTT, TTA, TTAT instruction.
--fpu linker option.
--import_cmse_lib_in linker option.
--import_cmse_lib_out linker option.
--scatter linker option.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-71
Non-Confidential
1 armclang Command-line Options
1.46 -mcpu
1.46 -mcpu
Enables code generation for a specific ARM processor.
Syntax
To specify a target processor, use:
-mcpu=name
Where:
name
Specifies the processor.
To view a list of all supported processors for your target, use:
-mcpu=list
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-72
Non-Confidential
1 armclang Command-line Options
1.46 -mcpu
feature
Is an optional architecture feature that might be enabled or disabled by default depending on the
architecture or processor.
Note
In general, if an architecture supports the optional feature, then this optional feature is enabled
by default. To determine whether the optional feature is enabled, use fromelf
--decode_build_attributes.
+feature enables the feature if it is disabled by default. +feature has no effect if the feature is
already enabled by default.
+nofeature disables the feature if it is enabled by default. +nofeature has no effect if the
feature is already disabled by default.
Use +feature or +nofeature to explicitly enable or disable an optional architecture feature.
For AArch64 targets you can specify one or more of the following features if the architecture
supports it:
• crc - CRC extension.
• crypto - Cryptographic extension.
• dotprod - Enables the SDOT and UDOT instructions. Supported in ARMv8.2 and later
Application profile architectures, and is OPTIONAL in ARMv8.2 and ARMv8.3.
• fp - Floating-point extension.
• fp16 - ARMv8.2-A half-precision floating-point extension.
• profile - ARMv8.2-A statistical profiling extension.
• ras - Reliability, Availability, and Serviceability extension.
• simd - Advanced SIMD extension.
• rcpc - Release Consistent Processor Consistent extension. This extension applies to
ARMv8.2 and later Application profile architectures.
For AArch32 targets, you can specify one or more of the following features if the architecture
supports it:
• crc - CRC extension for architectures ARMv8 and above.
• dotprod - Enables the VSDOT and VUDOT instructions. Supported in ARMv8.2 and later
Application profile architectures, and is OPTIONAL in ARMv8.2 and ARMv8.3.
• dsp - DSP extension for the ARMv8-M.mainline architecture.
• fp16 - ARMv8.2-A half-precision floating-point extension.
• ras - Reliability, Availability, and Serviceability extension.
Note
For AArch32 targets, you can use -mfpu to specify the support for floating-point, Advanced
SIMD, and cryptographic extensions.
Note
To write code that generates instructions for these extensions, use the intrinsics described in the ARM C
Language Extensions.
Usage
You can use -mcpu option to enable and disable specific architecture features.
To disable a feature, prefix with no, for example cortex-a57+nocrypto.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-73
Non-Confidential
1 armclang Command-line Options
1.46 -mcpu
To enable or disable multiple features, chain multiple feature modifiers. For example, to enable CRC
instructions and disable all other extensions:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a57+nocrypto+nofp+nosimd+crc
If you specify conflicting feature modifiers with -mcpu, the rightmost feature is used. For example, the
following command enables the floating-point extension:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a57+nofp+fp
You can prevent the use of floating-point instructions or floating-point registers for AArch64 targets with
the -mcpu=name+nofp+nosimd option. Subsequent use of floating-point data types in this mode is
unsupported.
Note
There are no software floating-point libraries for AArch64 targets. When linking for AArch64 targets,
armlink uses AArch64 libraries that contain floating-point and Advanced SIMD instructions and
registers. This applies even if you compile the source with -mcpu=<name>+nofp+nosimd to prevent the
compiler from using floating-point and Advanced SIMD instructions and registers. Therefore, there is no
guarantee that the linked image for AArch64 targets is entirely free of floating-point and Advanced
SIMD instructions and registers.
To prevent the use of floating-point and Advanced SIMD instructions and registers in images that are
linked for AArch64 targets, re-implement the library functions or create your own library that does not
use floating-point and Advanced SIMD instructions and registers.
Default
For AArch64 targets (--target=aarch64-arm-none-eabi), the compiler generates generic code for the
ARMv8-A architecture in AArch64 state by default.
For AArch32 targets (--target=arm-arm-none-eabi) there is no default. You must specify either -
march (to target an architecture) or -mcpu (to target a processor).
Examples
To list the processors that target the AArch64 state:
armclang --target=aarch64-arm-none-eabi -mcpu=list
Related references
1.43 -marm on page 1-68.
1.54 -mthumb on page 1-85.
1.64 --target on page 1-97.
1.49 -mfpu on page 1-78.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-74
Non-Confidential
1 armclang Command-line Options
1.46 -mcpu
Related information
Specifying a target architecture, processor, and instruction set.
Preventing the use of floating-point instructions and registers.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-75
Non-Confidential
1 armclang Command-line Options
1.47 -mexecute-only
1.47 -mexecute-only
Generates execute-only code, and prevents the compiler from generating any data accesses to code
sections.
To keep code and data in separate sections, the compiler disables literal pools and branch tables when
using the -mexecute-only option.
Restrictions
Execute-only code must be Thumb code.
Execute-only code is only supported for:
• Processors that support the ARMv8-M.baseline or ARMv8-M.mainline architecture.
• Processors that support the ARMv7-M architecture, such as the Cortex-M3.
If your application calls library functions, the library objects included in the image are not execute-only
compliant. You must ensure these objects are not assigned to an execute-only memory region.
Note
ARM does not provide libraries that are built without literal pools. The libraries still use literal pools,
even when you use the -mexecute-only option.
Note
Link Time Optimization does not honor the armclang -mexecute-only option. If you use the armclang
-flto or -Omax options, then the compiler cannot generate execute-only code.
Related information
Building applications for execute-only memory.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-76
Non-Confidential
1 armclang Command-line Options
1.48 -mfloat-abi
1.48 -mfloat-abi
Specifies whether to use hardware instructions or software library functions for floating-point operations,
and which registers are used to pass floating-point parameters and return values.
Syntax
-mfloat-abi=value
Note
The -mfloat-abi option is not valid with AArch64 targets. AArch64 targets use hardware floating-point
instructions and hardware floating-point linkage. However, you can prevent the use of floating-point
instructions or floating-point registers for AArch64 targets with the -mcpu=name+nofp+nosimd option.
Subsequent use of floating-point data types in this mode is unsupported.
Default
The default for --target=arm-arm-none-eabi is softfp.
Related references
1.49 -mfpu on page 1-78.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-77
Non-Confidential
1 armclang Command-line Options
1.49 -mfpu
1.49 -mfpu
Specifies the target FPU architecture, that is the floating-point hardware available on the target.
Syntax
To view a list of all the supported FPU architectures, use:
-mfpu=list
Note
-mfpu=list is rejected when targeting AArch64.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-78
Non-Confidential
1 armclang Command-line Options
1.49 -mfpu
fp-armv8
Enable the ARMv8 floating-point extension. Disable the cryptographic extension and the
Advanced SIMD extension.
neon-fp-armv8
Enable the ARMv8 floating-point extension and the Advanced SIMD extensions. Disable the
cryptographic extension.
crypto-neon-fp-armv8
Enable the ARMv8 floating-point extension, the cryptographic extension. and the Advanced
SIMD extension.
The -mfpu option overrides the default FPU option implied by the target architecture.
Note
• The -mfpu option is ignored with AArch64 targets, for example aarch64-arm-none-eabi. Use the -
mcpu option to override the default FPU for aarch64-arm-none-eabi targets. For example, to
prevent the use of floating-point instructions or floating-point registers for the aarch64-arm-none-
eabi target use the -mcpu=name+nofp+nosimd option. Subsequent use of floating-point data types in
this mode is unsupported.
• In ARMv7, the Advanced SIMD extension was called the NEON Advanced SIMD extension.
Note
There are no software floating-point libraries for AArch64 targets. When linking for AArch64 targets,
armlink uses AArch64 libraries that contain floating-point and Advanced SIMD instructions and
registers. This applies even if you compile the source with -mcpu=<name>+nofp+nosimd to prevent the
compiler from using floating-point and Advanced SIMD instructions and registers. Therefore, there is no
guarantee that the linked image for AArch64 targets is entirely free of floating-point and Advanced
SIMD instructions and registers.
To prevent the use of floating-point and Advanced SIMD instructions and registers in images that are
linked for AArch64 targets, re-implement the library functions or create your own library that does not
use floating-point and Advanced SIMD instructions and registers.
Default
The default FPU option depends on the target processor.
Related references
1.46 -mcpu on page 1-72.
1.48 -mfloat-abi on page 1-77.
1.64 --target on page 1-97.
Related information
Specifying a target architecture, processor, and instruction set.
Preventing the use of floating-point instructions and registers.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-79
Non-Confidential
1 armclang Command-line Options
1.50 -mimplicit-it
1.50 -mimplicit-it
Specifies the behavior of the integrated assembler if there are conditional instructions outside IT blocks.
-mimplicit-it=name
Note
This option has no effect in AArch64 state because the A64 instruction set does not include the IT
instruction. The integrated assembler gives a warning if you use the -mimplicit-it option for A64
code.
Default
The default is -mimplicit-it=arm.
Related information
IT.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-80
Non-Confidential
1 armclang Command-line Options
1.51 -mlittle-endian
1.51 -mlittle-endian
Generates code suitable for an ARM processor using little-endian data.
Default
The default is -mlittle-endian.
Related references
1.44 -mbig-endian on page 1-69.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-81
Non-Confidential
1 armclang Command-line Options
1.52 -mno-neg-immediates
1.52 -mno-neg-immediates
Disables the substitution of invalid instructions with valid equivalent instructions that use the logical
inverse or negative of the specified immediate value.
Syntax
-mno-neg-immediates
Usage
If an instruction does not have an encoding for the specified value of the immediate operand, but the
logical inverse or negative of the immediate operand is available, then armclang produces a valid
equivalent instruction and inverts or negates the specified immediate value. This applies to both
assembly language source files and to inline assembly code in C and C++ language source files.
For example, armclang substitutes the instruction sub r0, r0, #0xFFFFFF01 with the equivalent
instruction add r0, r0, #0xFF.
You can disable this substitution using the option -mno-neg-immediates. In this case, armclang
generates the error instruction requires: NegativeImmediates, if it encounters an invalid
instruction that can be substituted using the logical inverse or negative of the immediate value.
When you do not use the option -mno-neg-immediates, armclang is able to substitute instructions but
does not produce a diagnostic message when a substitution has occurred. When you are comparing
disassembly listings with source code, be aware that some instructions might have been substituted.
Default
By default, armclang substitutes invalid instructions with an alternative instruction if the substitution is a
valid equivalent instruction that produces the same result by using the logical inverse or negative of the
specified immediate value.
Example
Copy the following code to a file called neg.s.
.arm
sub r0, r0, #0xFFFFFF01
.thumb
subw r0, r1, #0xFFFFFF01
Assemble the file neg.s without the -mno-neg-immediates option to produce the output neg.o.
armclang --target=arm-arm-none-eabi -march=armv7-a -c neg.s -o neg.o
Note that the disassembly from neg.o contains substituted instructions ADD and ADDW:
** Section #2 '.text' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR]
Size : 8 bytes (alignment 4)
Address: 0x00000000
$a.0
0x00000000: e28000ff .... ADD r0,r0,#0xff
$t.1
0x00000004: f20100ff .... ADDW r0,r1,#0xff
Assemble the file neg.s with the -mno-neg-immediates option to produce the output neg.o.
armclang --target=arm-arm-none-eabi -march=armv7-a -c -mno-neg-immediates neg.s -o neg.o
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-82
Non-Confidential
1 armclang Command-line Options
1.52 -mno-neg-immediates
Note that armclang generates the error instruction requires: NegativeImmediates when
assembling this example with the -mno-neg-immediates option.
neg.s:2:2: error: instruction requires: NegativeImmediates
sub r0,#0xFFFFFF01
^
neg.s:4:2: error: instruction requires: NegativeImmediates
subw r0,r1,#0xFFFFFF01
^
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-83
Non-Confidential
1 armclang Command-line Options
1.53 -munaligned-access, -mno-unaligned-access
Default
-munaligned-access is the default for architectures that support unaligned accesses to data. This applies
to all architectures supported by ARM Compiler 6, except ARMv6-M and ARMv8-M.baseline.
Usage
-munaligned-access
Use this option on processors that support unaligned accesses to data, to speed up accesses to
packed structures.
Note
For ARMv6-M and ARMv8-M.baseline architectures, compiling with this option generates an
error.
-mno-unaligned-access
If unaligned access is disabled, any unaligned data that is wider than 8-bit is accessed one byte
at a time. For example, fields wider than 8-bit, in packed data structures, are always accessed
one byte at a time even if they are aligned.
Related references
6.2 Predefined macros on page 6-189.
Related information
ARM C Language Extensions 2.0.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-84
Non-Confidential
1 armclang Command-line Options
1.54 -mthumb
1.54 -mthumb
Requests that the compiler targets the T32 or Thumb® instruction sets.
Most ARMv7-A (and earlier) processors support two instruction sets: the ARM instruction set, and the
Thumb instruction set. ARMv8-A AArch32 continues to support these two instruction sets, but they are
renamed as A32 and T32 respectively. ARMv8-A additionally introduces the A64 instruction set, used in
the AArch64 execution state.
Different architectures support different instruction sets:
• ARMv8-A processors in AArch64 state execute A64 instructions.
• ARMv8-A processors in AArch32 state, in addition to ARMv7 and earlier A- and R- profile
processors execute A32 (formerly ARM) and T32 (formerly Thumb) instructions.
• M-profile processors execute T32 (formerly Thumb) instructions.
The -mthumb option targets the T32 (formerly Thumb) instruction set.
Note
• The -mthumb option is not valid with AArch64 targets, for example --target=aarch64-arm-none-
eabi. The compiler ignores the -mthumb option and generates a warning with AArch64 targets.
• The -mthumb option is recognized when using armclang as a compiler, but not when using it as an
assembler. To request armclang to assemble using the T32 or Thumb instruction set for your
assembly source files, you must use the .thumb or .code 16 directive in the assembly files.
Default
The default for all targets that support ARM or A32 instructions is -marm.
Example
armclang -c --target=arm-arm-none-eabi -march=armv8-a -mthumb test.c
Related references
1.43 -marm on page 1-68.
1.64 --target on page 1-97.
1.46 -mcpu on page 1-72.
Related information
Specifying a target architecture, processor, and instruction set.
Assembling ARM and GNU syntax assembly code.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-85
Non-Confidential
1 armclang Command-line Options
1.55 -nostdlib
1.55 -nostdlib
Tells the compiler to not use the ARM standard C and C++ libraries.
If you use the -nostdlib option, armclang does not collude with the ARM standard library and only
emits calls to AEABI compliant library functions. The output from armclang works with any ISO C
library that is compliant with AEABI.
The -nostdlib armclang option, passes the --no_scanlib linker option to armlink. Therefore you
must specify the location of the libraries you want to use as input objects to armlink, or with the --
userlibpath armlink option.
Note
If you want to use your own libraries instead of the ARM standard libraries or if you want to re-
implement the standard library functions, then you must use the -nostdlib armclang option. Your
libraries must be compliant with the ISO C library and with the AEABI specification.
Default
-nostdlib is disabled by default.
Example
#include "math.h"
double foo(double d)
{
return sqrt(d + 1.0);
}
int main(int argc, char *argv[])
{
return foo(argc);
}
Compiling this code with -nostdlib generates a call to sqrt (from the ARM standard library), which is
AEABI compliant.
armclang --target=arm-arm-none-eabi -mcpu=Cortex-A9 -O0 -S -o- file.c -mfloat-abi=hard -
nostdlib
Compiling this code without -nostdlib generates a call to __hardfp_sqrt (from the ARM standard
library), which is not AEABI compliant.
armclang --target=arm-arm-none-eabi -mcpu=Cortex-A9 -O0 -S -o- file.c -mfloat-abi=hard
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-86
Non-Confidential
1 armclang Command-line Options
1.56 -nostdlibinc
1.56 -nostdlibinc
Tells the compiler to exclude the ARM standard C and C++ library header files.
If you want to disable the use of the ARM standard library, then use the -nostdlibinc and -nostdlib
armclang options.
Default
-nostdlibinc is disabled by default.
Example
#include "math.h"
double foo(double d)
{
return sqrt(d + 1.0);
}
int main(int argc, char *argv[])
{
return foo(argc);
}
Compiling this code without -nostdlibinc generates a call to __hardfp_sqrt, from the ARM standard
library.
armclang --target=arm-arm-none-eabi -mcpu=Cortex-A9 -O0 -S -o- file.c -mfloat-abi=hard
Compiling this code with -nostdlibinc and -nostdlib generates an error because the compiler cannot
include the standard library header file math.h.
armclang --target=arm-arm-none-eabi -mcpu=Cortex-A9 -O0 -S -o- file.c -mfloat-abi=hard -
nostdlibinc -nostdlib
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-87
Non-Confidential
1 armclang Command-line Options
1.57 -o
1.57 -o
Specifies the name of the output file.
The option -o filename specifies the name of the output file produced by the compiler.
The option -o- redirects output to the standard output stream when used with the -c or -S options.
Default
If you do not specify a -o option, the compiler names the output file according to the conventions
described by the following table.
(No option) Produces temporary object files, then automatically calls the None of -o, -c, -E or -S is
linker to produce an executable image with the default name of specified on the command
a.out line
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-88
Non-Confidential
1 armclang Command-line Options
1.58 -O
1.58 -O
Specifies the level of optimization to use when compiling source files.
Syntax
-Olevel
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-89
Non-Confidential
1 armclang Command-line Options
1.58 -O
max
Maximum optimization. Specifically targets performance optimization. Enables all the
optimizations from level fast, together with other aggressive optimizations.
Caution
This option is not guaranteed to be fully standards-compliant for all code cases.
Caution
-Omax automatically enables the armclang -flto option and the generated object files are not
suitable for creating static libraries. When -flto is enabled, you cannot build ROPI or RWPI
images.
Note
When using -Omax:
• Code-size, build-time, and the debug view can each be adversely affected.
• ARM cannot guarantee that the best performance optimization is achieved in all code cases.
• It is not possible to output meaningful disassembly when the -flto option is enabled, which
is turned on by default at -Omax, because this generates files containing bitcode.
• If you are trying to compile at -Omax and have separate compile and link steps, then also
include -Omax on your armlink command line.
Note
Link Time Optimization does not honor the armclang -mexecute-only option. If you use the
armclang -flto or -Omax options, then the compiler cannot generate execute-only code.
s
Performs optimizations to reduce code size, balancing code size against code speed.
z
Performs optimizations to minimize image size.
Default
If you do not specify -Olevel, the compiler assumes -O0. For the best debug view, ARM recommends -
O1 rather than -O0 for the best trade-off between image size, performance, and debug.
Related references
1.18 -flto on page 1-41.
1.21 -fropi, -fno-ropi on page 1-44.
1.23 -frwpi, -fno-rwpi on page 1-46.
Related information
Restrictions with link time optimization.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-90
Non-Confidential
1 armclang Command-line Options
1.59 -pedantic
1.59 -pedantic
Generate warnings if code violates strict ISO C and ISO C++.
If you use the -pedantic option, the compiler generates warnings if your code uses any language feature
that conflicts with strict ISO C or ISO C++.
Default
-pedantic is disabled by default.
Example
void foo(void)
{
long long i; /* okay in nonstrict C90 */
}
Note
The -pedantic option is stricter than the -Wpedantic option.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-91
Non-Confidential
1 armclang Command-line Options
1.60 -pedantic-errors
1.60 -pedantic-errors
Generate errors if code violates strict ISO C and ISO C++.
If you use the -pedantic-errors option, the compiler does not use any language feature that conflicts
with strict ISO C or ISO C++. The compiler generates an error if your code violates strict ISO language
standard.
Default
-pedantic-errors is disabled by default.
Example
void foo(void)
{
long long i; /* okay in nonstrict C90 */
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-92
Non-Confidential
1 armclang Command-line Options
1.61 -S
1.61 -S
Outputs the disassembly of the machine code generated by the compiler.
Object modules are not generated. The name of the assembly output file defaults to filename.s in the
current directory, where filename is the name of the source file stripped of any leading directory names.
The default filename can be overridden with the -o option.
Note
It is not possible to output meaningful disassembly when the -flto option is enabled, which is turned on
by default at -Omax, because this generates files containing bitcode.
Related references
1.57 -o on page 1-88.
1.58 -O on page 1-89.
1.18 -flto on page 1-41.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-93
Non-Confidential
1 armclang Command-line Options
1.62 -save-temps
1.62 -save-temps
Instructs the compiler to generate intermediate assembly files from the specified C/C++ file.
It is similar to disassembling object code that has been compiled from C/C++.
Example
armclang --target=aarch64-arm-none-eabi -save-temps -c hello.c
Executing this command outputs the following files, that are listed in the order they are created:
• hello.i (or hello.ii for C++): the C or C++ file after pre-processing.
• hello.bc: the llvm-ir bitcode file.
• hello.s: the assembly file.
• hello.o: the output object file.
Note
• Specifying -c means that the compilation process stops after the compilation step, and does not do
any linking.
• Specifying -S means that the compilation process stops after the disassembly step, and does not
create an object file.
Related references
1.4 -c on page 1-26.
1.61 -S on page 1-93.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-94
Non-Confidential
1 armclang Command-line Options
1.63 -std
1.63 -std
Specifies the language standard to compile for.
Note
This topic includes descriptions of [BETA] and [COMMUNITY] features. See Support level definitions
on page 1-17.
Syntax
-std=name
Where:
name
Specifies the language mode. Valid values include:
c90
C as defined by the 1990 C standard.
gnu90
C as defined by the 1990 C standard, with additional GNU extensions.
c99
C as defined by the 1999 C standard.
gnu99
C as defined by the 1999 C standard, with additional GNU extensions.
c11 [COMMUNITY]
C as defined by the 2011 C standard.
gnu11 [COMMUNITY]
C as defined by the 2011 C standard, with additional GNU extensions.
c++98
C++ as defined by the 1998 standard.
gnu++98
C++ as defined by the 1998 standard, with additional GNU extensions.
c++03
C++ as defined by the 2003 standard.
c++11
C++ as defined by the 2011 standard.
gnu++11
C++ as defined by the 2011 standard, with additional GNU extensions.
c++14 [BETA]
C++ as defined by the 2014 standard.
gnu++14 [BETA]
C++ as defined by the 2014 standard, with additional GNU extensions.
For C++ code, the default is gnu++98. For more information about C++ support, see C++ Status on the
Clang web site.
For C code, the default is gnu11. For more information about C support, see Language Compatibility on
the Clang web site.
Note
Use of C11 library features is unsupported.
Related references
1.74 -x on page 1-107.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-95
Non-Confidential
1 armclang Command-line Options
1.63 -std
Related information
Language Compatibility.
C++ Status.
Language Support Levels.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-96
Non-Confidential
1 armclang Command-line Options
1.64 --target
1.64 --target
Generate code for the specified target triple.
Syntax
--target=triple
Where:
triple
has the form architecture-vendor-OS-abi.
Supported targets are as follows:
aarch64-arm-none-eabi
Generates A64 instructions for AArch64 state. Implies -march=armv8-a unless -mcpu or -
march is specified.
arm-arm-none-eabi
Generates A32/T32 instructions for AArch32 state. Must be used in conjunction with -march (to
target an architecture) or -mcpu (to target a processor).
Note
• The targets are case-sensitive.
• The --target option is an armclang option. For all of the other tools, such as armasm and armlink,
use the --cpu and --fpu options to specify target processors and architectures.
Default
The --target option is mandatory and has no default. You must always specify a target triple.
Related references
1.43 -marm on page 1-68.
1.54 -mthumb on page 1-85.
1.46 -mcpu on page 1-72.
1.49 -mfpu on page 1-78.
Related information
Specifying a target architecture, processor, and instruction set.
armasm User Guide.
armlink User Guide.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-97
Non-Confidential
1 armclang Command-line Options
1.65 -U
1.65 -U
Removes any initial definition of the specified macro.
Syntax
-Uname
Where:
name
is the name of the macro to be undefined.
The macro name can be either:
• A predefined macro.
• A macro specified using the -D option.
Note
Not all compiler predefined macros can be undefined.
Usage
Specifying -Uname has the same effect as placing the text #undef name at the head of each source file.
Restrictions
The compiler defines and undefines macros in the following order:
1. Compiler predefined macros.
2. Macros defined explicitly, using -Dname.
3. Macros explicitly undefined, using -Uname.
Related references
1.5 -D on page 1-27.
6.2 Predefined macros on page 6-189.
1.33 -include on page 1-57.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-98
Non-Confidential
1 armclang Command-line Options
1.66 -u
1.66 -u
Prevents the removal of a specified symbol if it is undefined.
Syntax
-u symbol
See the ARM® Compiler armlink User Guide for information about the --undefined linker option.
Related information
armlink User Guide.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-99
Non-Confidential
1 armclang Command-line Options
1.67 -v
1.67 -v
Displays the commands that invoke the compiler and linker, and executes those commands.
Usage
The -v compiler option produces diagnostic output showing exactly how the compiler and linker are
invoked, displaying the options for each tool. The -v compiler option also displays version information.
With the -v option, armclang displays this diagnostic output and executes the commands.
Note
To display the diagnostic output without executing the commands, use the -### option.
Related references
1.75 -### on page 1-108.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-100
Non-Confidential
1 armclang Command-line Options
1.68 --version
1.68 --version
Displays the same information as --vsn.
Related references
1.70 --vsn on page 1-103.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-101
Non-Confidential
1 armclang Command-line Options
1.69 --version_number
1.69 --version_number
Displays the version of armclang you are using.
Usage
The compiler displays the version number in the format Mmmuuxx, where:
• M is the major version number, 6.
• mm is the minor version number.
• uu is the update number.
• xx is reserved for ARM internal use. You can ignore this for the purposes of checking whether the
current release is a specific version or within a range of versions.
Related references
6.2 Predefined macros on page 6-189.
1.70 --vsn on page 1-103.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-102
Non-Confidential
1 armclang Command-line Options
1.70 --vsn
1.70 --vsn
Displays the version information and the license details.
Note
--vsn is intended to report the version information for manual inspection. The Component line indicates
the release of ARM Compiler you are using. If you need to access the version in other tools or scripts, for
example in build scripts, use the output from --version_number.
Example
Example output:
> armclang --vsn
Product: ARM Compiler N.n.p
Component: ARM Compiler N.n.p
Tool: armclang [tool_id]
Target: target_name
Related references
1.68 --version on page 1-101.
1.69 --version_number on page 1-102.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-103
Non-Confidential
1 armclang Command-line Options
1.71 -W
1.71 -W
Controls diagnostics.
Syntax
-Wname
Related information
Options for controlling diagnostics with armclang.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-104
Non-Confidential
1 armclang Command-line Options
1.72 -Wl
1.72 -Wl
Specifies linker command-line options to pass to the linker when a link step is being performed after
compilation.
See the ARM® Compiler armlink User Guide for information about available linker options.
Syntax
-Wl,opt,[opt[,...]]
Where:
opt
is a linker command-line option to pass to the linker.
You can specify a comma-separated list of options or option=argument pairs.
Restrictions
The linker generates an error if -Wl passes unsupported options.
Examples
The following examples show the different syntax usages. They are equivalent because armlink treats
the single option --list=diag.txt and the two options --list diag.txt equivalently:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 hello.c -Wl,--split,--list,diag.txt
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 hello.c -Wl,--split,--list=diag.txt
Related references
1.73 -Xlinker on page 1-106.
Related information
ARM Compiler Linker Command-line Options.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-105
Non-Confidential
1 armclang Command-line Options
1.73 -Xlinker
1.73 -Xlinker
Specifies linker command-line options to pass to the linker when a link step is being performed after
compilation.
See the ARM® Compiler armlink User Guide for information about available linker options.
Syntax
-Xlinker opt
Where:
opt
is a linker command-line option to pass to the linker.
If you want to pass multiple options, use multiple -Xlinker options.
Restrictions
The linker generates an error if -Xlinker passes unsupported options.
Examples
This example passes the option --split to the linker:
armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 hello.c -Xlinker --split
Related references
1.72 -Wl on page 1-105.
Related information
ARM Compiler Linker Command-line Options.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-106
Non-Confidential
1 armclang Command-line Options
1.74 -x
1.74 -x
Specifies the language of source files.
Syntax
-x language
Where:
language
Specifies the language of subsequent source files, one of the following:
c
C code.
c++
C++ code.
assembler-with-cpp
Assembly code containing C directives that require the C preprocessor.
assembler
Assembly code that does not require the C preprocessor.
Usage
-x overrides the default language standard for the subsequent input files that follow it on the command-
line. For example:
armclang inputfile1.s -xc inputfile2.s inputfile3.s
Note
Use -std to set the default language standard.
Default
By default the compiler determines the source file language from the filename suffix, as follows:
• .cpp, .cxx, .c++, .cc, and .CC indicate C++, equivalent to -x c++.
• .c indicates C, equivalent to -x c.
• .s (lower-case) indicates assembly code that does not require preprocessing, equivalent to -x
assembler.
• .S (upper-case) indicates assembly code that requires preprocessing, equivalent to -x assembler-
with-cpp.
Related references
1.5 -D on page 1-27.
1.63 -std on page 1-95.
Related information
Preprocessing assembly code.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-107
Non-Confidential
1 armclang Command-line Options
1.75 -###
1.75 -###
Displays the commands that invoke the compiler and sub-tools, such as armlink, without executing
those commands.
Usage
The -### compiler option produces diagnostic output showing exactly how the compiler and linker are
invoked, displaying the options for each tool. The -### compiler option also displays version
information.
With the -### option, armclang only displays this diagnostic output. armclang does not compile source
files or invoke armlink.
Note
To display the diagnostic output and execute the commands, use the -v option.
Related references
1.67 -v on page 1-100.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 1-108
Non-Confidential
Chapter 2
Compiler-specific Keywords and Operators
Summarizes the compiler-specific keywords and operators that are extensions to the C and C++
Standards.
It contains the following sections:
• 2.1 Compiler-specific keywords and operators on page 2-110.
• 2.2 __alignof__ on page 2-111.
• 2.3 __asm on page 2-113.
• 2.4 __declspec attributes on page 2-115.
• 2.5 __declspec(noinline) on page 2-116.
• 2.6 __declspec(noreturn) on page 2-117.
• 2.7 __declspec(nothrow) on page 2-118.
• 2.8 __inline on page 2-119.
• 2.9 __unaligned on page 2-120.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-109
Non-Confidential
2 Compiler-specific Keywords and Operators
2.1 Compiler-specific keywords and operators
Related references
2.2 __alignof__ on page 2-111.
2.3 __asm on page 2-113.
2.4 __declspec attributes on page 2-115.
2.8 __inline on page 2-119.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-110
Non-Confidential
2 Compiler-specific Keywords and Operators
2.2 __alignof__
2.2 __alignof__
The __alignof__ keyword enables you to inquire about the alignment of a type or variable.
Note
This keyword is a GNU compiler extension that the ARM compiler supports.
Syntax
__alignof__(type)
__alignof__(expr)
Where:
type
is a type
expr
is an lvalue.
Return value
__alignof__(type) returns the alignment requirement for the type, or 1 if there is no alignment
requirement.
__alignof__(expr) returns the alignment requirement for the type of the lvalue expr, or 1 if there is no
alignment requirement.
Example
The following example displays the alignment requirements for a variety of data types, first directly from
the data type, then from an lvalue of the corresponding data type:
#include <stdio.h>
int main(void)
{
int var_i;
char var_c;
double var_d;
float var_f;
long var_l;
long long var_ll;
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-111
Non-Confidential
2 Compiler-specific Keywords and Operators
2.2 __alignof__
long : 4
long long : 8
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-112
Non-Confidential
2 Compiler-specific Keywords and Operators
2.3 __asm
2.3 __asm
This keyword passes information to the armclang assembler.
The precise action of this keyword depends on its usage.
Usage
Inline assembly
The __asm keyword can incorporate inline GCC syntax assembly code into a function. For
example:
#include <stdio.h>
int main(void)
{
int a = 1;
int b = 2;
int c = 0;
c = add(a,b);
code is the assembly code. In our example, this is "ADD %[result], %[input_i], %
[input_j]".
Naked functions with the __attribute__((naked)) function attribute only support assembler
instructions in the basic format:
__asm(code);
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-113
Non-Confidential
2 Compiler-specific Keywords and Operators
2.3 __asm
Assembly labels
The __asm keyword can specify an assembly label for a C symbol. For example:
int count __asm__("count_v1"); // export count_v1, not count
Related references
3.10 __attribute__((naked)) function attribute on page 3-133.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-114
Non-Confidential
2 Compiler-specific Keywords and Operators
2.4 __declspec attributes
Related references
2.5 __declspec(noinline) on page 2-116.
2.6 __declspec(noreturn) on page 2-117.
2.7 __declspec(nothrow) on page 2-118.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-115
Non-Confidential
2 Compiler-specific Keywords and Operators
2.5 __declspec(noinline)
2.5 __declspec(noinline)
The __declspec(noinline) attribute suppresses the inlining of a function at the call points of the
function.
__declspec(noinline) can also be applied to constant data, to prevent the compiler from using the
value for optimization purposes, without affecting its placement in the object. This is a feature that can
be used for patchable constants, that is, data that is later patched to a different value. It is an error to try
to use such constants in a context where a constant value is required. For example, an array dimension.
Note
This __declspec attribute has the function attribute equivalent __attribute__((noinline)).
Example
/* Prevent y being used for optimization */
__declspec(noinline) const int y = 5;
/* Suppress inlining of foo() wherever foo() is called */
__declspec(noinline) int foo(void);
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-116
Non-Confidential
2 Compiler-specific Keywords and Operators
2.6 __declspec(noreturn)
2.6 __declspec(noreturn)
The __declspec(noreturn) attribute asserts that a function never returns.
Note
This __declspec attribute has the function attribute equivalent __attribute__((noreturn)).
Usage
Use this attribute to reduce the cost of calling a function that never returns, such as exit(). If a
noreturn function returns to its caller, the behavior is undefined.
Restrictions
The return address is not preserved when calling the noreturn function. This limits the ability of a
debugger to display the call stack.
Example
__declspec(noreturn) void overflow(void); // never return on overflow
int negate(int x)
{
if (x == 0x80000000) overflow();
return -x;
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-117
Non-Confidential
2 Compiler-specific Keywords and Operators
2.7 __declspec(nothrow)
2.7 __declspec(nothrow)
The __declspec(nothrow) attribute asserts that a call to a function never results in a C++ exception
being propagated from the callee into the caller.
The ARM library headers automatically add this qualifier to declarations of C functions that, according
to the ISO C Standard, can never throw an exception. However, there are some restrictions on the
unwinding tables produced for the C library functions that might throw an exception in a C++ context,
for example, bsearch and qsort.
Note
This __declspec attribute has the function attribute equivalent __attribute__((nothrow)).
Usage
If the compiler knows that a function can never throw an exception, it might be able to generate smaller
exception-handling tables for callers of that function.
Restrictions
If a call to a function results in a C++ exception being propagated from the callee into the caller, the
behavior is undefined.
This modifier is ignored when not compiling with exceptions enabled.
Example
struct S
{
~S();
};
__declspec(nothrow) extern void f(void);
void g(void)
{
S s;
f();
}
Related information
Standard C++ library implementation definition.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-118
Non-Confidential
2 Compiler-specific Keywords and Operators
2.8 __inline
2.8 __inline
The __inline keyword suggests to the compiler that it compiles a C or C++ function inline, if it is
sensible to do so.
__inline can be used in C90 code, and serves as an alternative to the C99 inline keyword.
Example
static __inline int f(int x){
return x*5+1;
}
Related concepts
6.3 Inline functions on page 6-194.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-119
Non-Confidential
2 Compiler-specific Keywords and Operators
2.9 __unaligned
2.9 __unaligned
The __unaligned keyword is a type qualifier that tells the compiler to treat the pointer or variable as an
unaligned pointer or variable.
Members of packed structures might be unaligned. Use the __unaligned keyword on pointers that you
use for accessing packed structures or members of packed structures.
Example
typedef struct __attribute__((packed)) S{
char c;
int x;
};
The compiler generates an error if you assign an unaligned pointer to a regular pointer without type
casting.
Example
struct __attribute__((packed)) S { char c; int x; };
void foo(__unaligned struct S *s2)
{
int *p = &s2->x; // compiler error because &s2->x is an unaligned pointer
but p is a regular pointer.
__unaligned int *q = &s2->x; // No error because q and &s2->x are both unaligned
pointers.
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 2-120
Non-Confidential
Chapter 3
Compiler-specific Function, Variable, and Type
Attributes
Summarizes the compiler-specific function, variable, and type attributes that are extensions to the C and
C++ Standards.
It contains the following sections:
• 3.1 Function attributes on page 3-123.
• 3.2 __attribute__((always_inline)) function attribute on page 3-125.
• 3.3 __attribute__((cmse_nonsecure_call)) function attribute on page 3-126.
• 3.4 __attribute__((cmse_nonsecure_entry)) function attribute on page 3-127.
• 3.5 __attribute__((const)) function attribute on page 3-128.
• 3.6 __attribute__((constructor[(priority)])) function attribute on page 3-129.
• 3.7 __attribute__((format_arg(string-index))) function attribute on page 3-130.
• 3.8 __attribute__((interrupt("type"))) function attribute on page 3-131.
• 3.9 __attribute__((malloc)) function attribute on page 3-132.
• 3.10 __attribute__((naked)) function attribute on page 3-133.
• 3.11 __attribute__((noinline)) function attribute on page 3-134.
• 3.12 __attribute__((nonnull)) function attribute on page 3-135.
• 3.13 __attribute__((noreturn)) function attribute on page 3-136.
• 3.14 __attribute__((nothrow)) function attribute on page 3-137.
• 3.15 __attribute__((pcs("calling_convention"))) function attribute on page 3-138.
• 3.16 __attribute__((pure)) function attribute on page 3-139.
• 3.17 __attribute__((section("name"))) function attribute on page 3-140.
• 3.18 __attribute__((used)) function attribute on page 3-141.
• 3.19 __attribute__((unused)) function attribute on page 3-142.
• 3.20 __attribute__((value_in_regs)) function attribute on page 3-143.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-121
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-122
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.1 Function attributes
For example:
int my_function(int b) __attribute__((const));
static int my_variable __attribute__((__unused__));
Table 3-1 Function attributes that the compiler supports, and their equivalents
__attribute__((nomerge)) -
__attribute__((nonnull)) -
__attribute__((noreturn)) __declspec(noreturn))
__attribute__((nothrow)) __delspec(nothrow)
__attribute__((notailcall)) -
__attribute__((pcs("calling_convention"))) -
__attribute__((pure)) -
__attribute__((section("name"))) -
__attribute__((unused)) -
__attribute__((used)) -
__attribute__((visibility("visibility_type"))) -
__attribute__((weak)) -
__attribute__((weakref("target"))) -
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-123
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.1 Function attributes
Usage
You can set these function attributes in the declaration, the definition, or both. For example:
void AddGlobals(void) __attribute__((always_inline));
__attribute__((always_inline)) void AddGlobals(void) {...}
When function attributes conflict, the compiler uses the safer or stronger one. For example,
__attribute__((used)) is safer than __attribute__((unused)), and __attribute__((noinline))
is safer than __attribute__((always_inline)).
Related references
3.2 __attribute__((always_inline)) function attribute on page 3-125.
3.5 __attribute__((const)) function attribute on page 3-128.
3.6 __attribute__((constructor[(priority)])) function attribute on page 3-129.
3.7 __attribute__((format_arg(string-index))) function attribute on page 3-130.
3.9 __attribute__((malloc)) function attribute on page 3-132.
3.12 __attribute__((nonnull)) function attribute on page 3-135.
3.10 __attribute__((naked)) function attribute on page 3-133.
3.15 __attribute__((pcs("calling_convention"))) function attribute on page 3-138.
3.11 __attribute__((noinline)) function attribute on page 3-134.
3.14 __attribute__((nothrow)) function attribute on page 3-137.
3.17 __attribute__((section("name"))) function attribute on page 3-140.
3.16 __attribute__((pure)) function attribute on page 3-139.
3.13 __attribute__((noreturn)) function attribute on page 3-136.
3.19 __attribute__((unused)) function attribute on page 3-142.
3.18 __attribute__((used)) function attribute on page 3-141.
3.21 __attribute__((visibility("visibility_type"))) function attribute on page 3-145.
3.22 __attribute__((weak)) function attribute on page 3-146.
3.23 __attribute__((weakref("target"))) function attribute on page 3-147.
2.2 __alignof__ on page 2-111.
2.3 __asm on page 2-113.
2.4 __declspec attributes on page 2-115.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-124
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.2 __attribute__((always_inline)) function attribute
Example
static int max(int x, int y) __attribute__((always_inline));
static int max(int x, int y)
{
return x > y ? x : y; // always inline if possible
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-125
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.3 __attribute__((cmse_nonsecure_call)) function attribute
Example
#include <arm_cmse.h>
typedef void __attribute__((cmse_nonsecure_call)) nsfunc(void);
void default_callback(void) { … }
void call_callback(void) {
if (cmse_is_nsfptr(fp)){
fp(); // non-secure function call
}
else {
((void (*)(void)) fp)(); // normal function call
}
}
Related references
3.4 __attribute__((cmse_nonsecure_entry)) function attribute on page 3-127.
6.6 Non-secure function pointer intrinsics on page 6-199.
Related information
Building Secure and Non-secure Images Using ARMv8-M Security Extensions.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-126
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.4 __attribute__((cmse_nonsecure_entry)) function attribute
Syntax
C linkage:
void __attribute__((cmse_nonsecure_entry)) entry_func(int val)
C++ linkage:
extern "C" void __attribute__((cmse_nonsecure_entry)) entry_func(int val)
Note
Compile Secure code with the maximum capabilities for the target. For example, if you compile with no
FPU then the Secure functions do not clear floating-point registers when returning from functions
declared as __attribute__((cmse_nonsecure_entry)). Therefore, the functions could potentially leak
sensitive data.
Example
#include <arm_cmse.h>
void __attribute__((cmse_nonsecure_entry)) entry_func(int val) {
int state = cmse_nonsecure_caller();
if (state)
{ // called from non-secure
// do non-secure work
...
} else
{ // called from within secure
// do secure work
...
}
}
Related references
3.3 __attribute__((cmse_nonsecure_call)) function attribute on page 3-126.
6.6 Non-secure function pointer intrinsics on page 6-199.
Related information
Building Secure and Non-secure Images Using ARMv8-M Security Extensions.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-127
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.5 __attribute__((const)) function attribute
Example
#include <stdio.h>
int main(void) {
int i;
int result;
for (i = 0; i < 10; i++)
{
result = my_double(i);
printf (" i = %d ; result = %d \n", i, result);
}
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-128
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.6 __attribute__((constructor[(priority)])) function attribute
Syntax
__attribute__((constructor[(priority)]))
Where priority is an optional integer value denoting the priority. A constructor with a low integer
value runs before a constructor with a high integer value. A constructor with a priority runs before a
constructor without a priority.
Priority values up to and including 100 are reserved for internal use. If you use these values, the compiler
gives a warning.
Usage
You can use this attribute for start-up or initialization code.
Example
In the following example, the constructor functions are called before execution enters main(), in the
order specified:
#include <stdio.h>
void my_constructor1(void) __attribute__((constructor));
void my_constructor2(void) __attribute__((constructor(102)));
void my_constructor3(void) __attribute__((constructor(103)));
void my_constructor1(void) /* This is the 3rd constructor */
{ /* function to be called */
printf("Called my_constructor1()\n");
}
void my_constructor2(void) /* This is the 1st constructor */
{ /* function to be called */
printf("Called my_constructor2()\n");
}
void my_constructor3(void) /* This is the 2nd constructor */
{ /* function to be called */
printf("Called my_constructor3()\n");
}
int main(void)
{
printf("Called main()\n");
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-129
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.7 __attribute__((format_arg(string-index))) function attribute
This attribute causes the compiler to perform placeholder type checking on the specified argument when
the output of the function is used in calls to a printf-style function.
Syntax
__attribute__((format_arg(string-index)))
Where string-index specifies the argument that is the format string argument (starting from one).
Example
The following example declares two functions, myFormatText1() and myFormatText2(), that provide
format strings to printf().
The first function, myFormatText1(), does not specify the format_arg attribute. The compiler does not
check the types of the printf arguments for consistency with the format string.
The second function, myFormatText2(), specifies the format_arg attribute. In the subsequent calls to
printf(), the compiler checks that the types of the supplied arguments a and b are consistent with the
format string argument to myFormatText2(). The compiler produces a warning when a float is
provided where an int is expected.
#include <stdio.h>
int main(void) {
int a;
float b;
a = 5;
b = 9.099999;
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-130
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.8 __attribute__((interrupt("type"))) function attribute
Syntax
__attribute__((interrupt("type")))
Usage
The interrupt attribute affects the code generation of a function as follows:
• If the function is AAPCS, the stack is realigned to 8 bytes on entry.
• For processors that are not based on the M-profile, preserves all processor registers, rather than only
the registers that the AAPCS requires to be preserved. Floating-point registers are not preserved.
• For processors that are not based on the M-profile, the function returns using an instruction that is
architecturally defined as a return from exception.
Restrictions
When using __attribute__((interrupt("type"))) functions:
• No arguments or return values can be used with the functions.
• The functions are incompatible with -frwpi.
Note
In ARMv6-M, ARMv7-M, and ARMv8-M, the architectural exception handling mechanism preserves all
processor registers, and a standard function return can cause an exception return. Therefore, specifying
the interrupt attribute does not affect the behavior of the compiled output. However, ARM
recommends using the interrupt attribute on exception handlers for clarity and easier software porting.
Note
• For architectures that support A32 and T32 instructions, functions specified with the interrupt
attribute compile to A32 or T32 code depending on whether the compile option specifies ARM or
Thumb.
• For Thumb only architectures, for example ARMv6-M, functions specified with the interrupt
attribute compile to T32 code.
• The interrupt attribute is not available for A64 code.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-131
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.9 __attribute__((malloc)) function attribute
Example
void * foo(int b) __attribute__((malloc));
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-132
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.10 __attribute__((naked)) function attribute
The compiler only supports basic __asm statements in __attribute__((naked)) functions. Using
extended assembly, parameter references or mixing C code with __asm statements might not work
reliably.
Related references
2.3 __asm on page 2-113.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-133
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.11 __attribute__((noinline)) function attribute
Example
/* Prevent y being used for optimization */
const int y = 5 __attribute__((noinline));
/* Suppress inlining of foo() wherever foo() is called */
int foo(void) __attribute__((noinline));
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-134
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.12 __attribute__((nonnull)) function attribute
Syntax
__attribute__((nonnull[(arg-index, ...)]))
Examples
The following declarations are equivalent:
void * my_memcpy (void *dest, const void *src, size_t len) __attribute__((nonnull (1, 2)));
void * my_memcpy (void *dest, const void *src, size_t len) __attribute__((nonnull));
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-135
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.13 __attribute__((noreturn)) function attribute
Usage
Use this attribute to reduce the cost of calling a function that never returns, such as exit(). If a noreturn
function returns to its caller, the behavior is undefined.
Restrictions
The return address is not preserved when calling the noreturn function. This limits the ability of a
debugger to display the call stack.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-136
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.14 __attribute__((nothrow)) function attribute
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-137
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.15 __attribute__((pcs("calling_convention"))) function attribute
Syntax
__attribute__((pcs("calling_convention")))
Example
double foo (float) __attribute__((pcs("aapcs")));
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-138
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.16 __attribute__((pure)) function attribute
Example
int bar(int b) __attribute__((pure));
int bar(int b)
{
return b++;
}
int foo(int b)
{
int aLocal=0;
aLocal += bar(b);
aLocal += bar(b);
return 0;
}
The call to bar in this example might be eliminated because its result is not used.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-139
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.17 __attribute__((section("name"))) function attribute
Example
In the following example, the function foo is placed into an RO section named new_section rather
than .text.
int foo(void) __attribute__((section ("new_section")));
int foo(void)
{
return 2;
}
Note
Section names must be unique. You must not use the same section name for different section types. If
you use the same section name for different section types, then the compiler merges the sections into one
and gives the section the type of whichever function or variable is first allocated to that section.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-140
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.18 __attribute__((used)) function attribute
Example
static int lose_this(int);
static int keep_this(int) __attribute__((used)); // retained in object file
static int keep_this_too(int) __attribute__((used)); // retained in object file
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-141
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.19 __attribute__((unused)) function attribute
Note
By default, the compiler does not warn about unused functions. Use -Wunused-function to enable this
warning specifically, or use an encompassing -W value such as -Wall.
The __attribute__((unused)) attribute can be useful if you usually want to warn about unused
functions, but want to suppress warnings for a specific set of functions.
Example
static int unused_no_warning(int b) __attribute__((unused));
static int unused_no_warning(int b)
{
return b++;
}
Related references
3.35 __attribute__((unused)) variable attribute on page 3-159.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-142
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.20 __attribute__((value_in_regs)) function attribute
Note
When using __attribute__((value_in_regs)), the calling convention only uses integer registers.
Syntax
__attribute__((value_in_regs)) return-type function-name([argument-list]);
Where:
return-type
is the type of the returned structure that conforms to certain restrictions as described below.
Usage
Declaring a function __attribute__((value_in_regs)) can be useful when calling functions that
return more than one result.
Restrictions
When targeting AArch32, the returned structure can be up to 16 bytes to fit in four 32-bit argument
registers. When targeting AArch64, the returned structure can be up to 64 bytes to fit in eight 64-bit
argument registers. If the structure returned by a function qualified by
__attribute__((value_in_regs)) is too big, the compiler generates an error.
Each field of the returned structure must occupy exactly one or two integer registers, and must not
require implicit padding of the structure. Anything else, including bitfields, is incompatible.
Nested structures are allowed with the same restriction that the nested structure as a whole and its
individual members must occupy exactly one or two integer registers.
Unions are allowed if they have at least one maximal-size member that occupies exactly one or two
integer registers. The other fields within the union can have any field type.
The allowed field types are:
• signed int (AArch32 only).
• unsigned int (AArch32 only).
• signed long.
• unsigned long.
• signed long long.
• unsigned long long.
• pointer.
• structure containing any of the types in this list.
• union whose maximal-size member is any of the types in this list.
If the structure type returned by a function qualified by __attribute__((value_in_regs)) violates any
of the above rules, then the compiler generates the corresponding error.
If a virtual function declared as __attribute__((value_in_regs)) is to be overridden, the overriding
function must also be declared as __attribute__((value_in_regs)). If the functions do not match, the
compiler generates an error.
A function declared as __attribute__((value_in_regs)) is not function-pointer-compatible with a
normal function of the same type signature. If a pointer to a function that is declared as
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-143
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.20 __attribute__((value_in_regs)) function attribute
The return type of a function declared as__attribute__((value_in_regs)) must be known at the point
of the function declaration. The compiler generates a corresponding error if the return type is an
incomplete type.
Example
struct ReturnType
{
long a;
void *ptr;
union U
{
char c;
short s;
int i;
float f;
double d;
struct S1 {long long ll;} s1;
} u;
};
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-144
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.21 __attribute__((visibility("visibility_type"))) function attribute
Syntax
__attribute__((visibility("visibility_type")))
Usage
Except when specifying default visibility, this attribute is intended for use with declarations that would
otherwise have external linkage.
You can apply this attribute to functions and variables in C and C++. In C++, it can also be applied to
class, struct, union, and enum types, and namespace declarations.
In the case of namespace declarations, the visibility attribute applies to all function and variable
definitions.
Example
void __attribute__((visibility("protected"))) foo()
{
...
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-145
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.22 __attribute__((weak)) function attribute
Example
extern int Function_Attributes_weak_0 (int b) __attribute__((weak));
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-146
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.23 __attribute__((weakref("target"))) function attribute
Syntax
__attribute__((weakref("target")))
Example
In the following example, foo() calls y() through a weak reference:
extern void y(void);
static void x(void) __attribute__((weakref("y")));
void foo (void)
{
...
x();
...
}
Restrictions
This attribute can only be used on functions with static linkage.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-147
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.24 Type attributes
For example:
typedef union { int i; float f; } U __attribute__((transparent_union));
Related references
3.25 __attribute__((aligned)) type attribute on page 3-149.
3.27 __attribute__((transparent_union)) type attribute on page 3-151.
3.26 __attribute__((packed)) type attribute on page 3-150.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-148
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.25 __attribute__((aligned)) type attribute
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-149
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.26 __attribute__((packed)) type attribute
Note
You must access a packed member of a struct or union directly from a variable of the containing type.
Taking the address of such a member produces a normal pointer which might be unaligned. The compiler
assumes that the pointer is aligned. Dereferencing such a pointer can be unsafe even when unaligned
accesses are supported by the target, because certain instructions always require word-aligned addresses.
Note
If you take the address of a packed member, in most cases, the compiler generates a warning.
When you specify __attribute__((packed)) to a structure or union, it applies to all members of the
structure or union. If a packed structure has a member that is also a structure, then this member structure
has an alignment of 1-byte. However, the packed attribute does not apply to the members of the member
structure. The members of the member structure continue to have their natural alignment.
Related references
1.53 -munaligned-access, -mno-unaligned-access on page 1-84.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-150
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.27 __attribute__((transparent_union)) type attribute
Example
typedef union { int i; float f; } U __attribute__((transparent_union));
void foo(U u)
{
static int s;
s += u.i; /* Use the 'int' field */
}
void caller(void)
{
foo(1); /* u.i is set to 1 */
foo(1.0f); /* u.f is set to 1.0f */
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-151
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.28 Variable attributes
For example:
static int b __attribute__((__unused__));
Related references
3.29 __attribute__((alias)) variable attribute on page 3-153.
3.30 __attribute__((aligned)) variable attribute on page 3-154.
3.31 __attribute__((deprecated)) variable attribute on page 3-155.
3.32 __attribute__((packed)) variable attribute on page 3-156.
3.33 __attribute__((section("name"))) variable attribute on page 3-157.
3.35 __attribute__((unused)) variable attribute on page 3-159.
3.34 __attribute__((used)) variable attribute on page 3-158.
3.36 __attribute__((weak)) variable attribute on page 3-160.
3.37 __attribute__((weakref("target"))) variable attribute on page 3-161.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-152
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.29 __attribute__((alias)) variable attribute
Note
Aliases cannot be specified in block scope. The compiler ignores aliasing attributes attached to local
variable definitions and treats the variable definition as a normal local definition.
In the output object file, the compiler replaces alias references with a reference to the original variable
name, and emits the alias alongside the original name. For example:
int oldname = 1;
extern int newname __attribute__((alias("oldname")));
Note
Function names can also be aliased using the corresponding function attribute
__attribute__((alias)).
Syntax
type newname __attribute__((alias("oldname")));
Where:
oldname
is the name of the variable to be aliased
newname
is the new name of the aliased variable.
Example
#include <stdio.h>
int oldname = 1;
extern int newname __attribute__((alias("oldname"))); // declaration
void foo(void){
printf("newname = %d\n", newname); // prints 1
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-153
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.30 __attribute__((aligned)) variable attribute
Example
/* Aligns on 16-byte boundary */
int x __attribute__((aligned (16)));
/* In this case, the alignment used is the maximum alignment for a scalar data type. For
ARM, this is 8 bytes. */
short my_array[3] __attribute__((aligned));
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-154
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.31 __attribute__((deprecated)) variable attribute
Example
extern int deprecated_var __attribute__((deprecated));
void foo()
{
deprecated_var=1;
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-155
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.32 __attribute__((packed)) variable attribute
Example
struct
{
char a;
int b __attribute__((packed));
} Variable_Attributes_packed_0;
Note
You must access a packed member of a structure or union directly from a variable of the structure or
union. Taking the address of such a member produces a normal pointer which might be unaligned. The
compiler assumes that the pointer is aligned. Dereferencing such a pointer can be unsafe even when
unaligned accesses are supported by the target, because certain instructions always require word-aligned
addresses.
Note
If you take the address of a packed member, in most cases, the compiler generates a warning.
Related references
3.30 __attribute__((aligned)) variable attribute on page 3-154.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-156
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.33 __attribute__((section("name"))) variable attribute
Example
/* in RO section */
const int descriptor[3] __attribute__((section ("descr"))) = { 1,2,3 };
/* in RW section */
long long rw_initialized[10] __attribute__((section ("INITIALIZED_RW"))) = {5};
/* in RW section */
long long rw[10] __attribute__((section ("RW")));
/* in ZI section */
int my_zi __attribute__((section (".bss.my_zi_section")));
Note
Section names must be unique. You must not use the same section name for different section types. If
you use the same section name for different section types, then the compiler merges the sections into one
and gives the section the type of whichever function or variable is first allocated to that section.
Related information
Manually placing __at sections.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-157
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.34 __attribute__((used)) variable attribute
Example
static int lose_this = 1;
static int keep_this __attribute__((used)) = 2; // retained in object file
static int keep_this_too __attribute__((used)) = 3; // retained in object file
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-158
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.35 __attribute__((unused)) variable attribute
Note
By default, the compiler does not warn about unused variables. Use -Wunused-variable to enable this
warning specifically, or use an encompassing -W value such as -Weverything.
The __attribute__((unused)) attribute can be used to warn about most unused variables, but suppress
warnings for a specific set of variables.
Example
void foo()
{
static int aStatic =0;
int aUnused __attribute__((unused));
int bUnused;
aStatic++;
}
When compiled with a suitable -W setting, the compiler warns that bUnused is declared but never
referenced, but does not warn about aUnused:
armclang --target=aarch64-arm-none-eabi -c test_unused.c -Wall
Related references
3.19 __attribute__((unused)) function attribute on page 3-142.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-159
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.36 __attribute__((weak)) variable attribute
At link time, strong symbols override weak symbols. This attribute replaces a weak symbol with a strong
symbol, by choosing a particular combination of object files to link.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-160
Non-Confidential
3 Compiler-specific Function, Variable, and Type Attributes
3.37 __attribute__((weakref("target"))) variable attribute
Syntax
__attribute__((weakref("target")))
Example
In the following example, a is assigned the value of y through a weak reference:
extern int y;
static int x __attribute__((weakref("y")));
void foo (void)
{
int a = x;
...
}
Restrictions
This attribute can only be used on variables that are declared as static.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 3-161
Non-Confidential
Chapter 4
Compiler-specific Intrinsics
Summarizes the ARM compiler-specific intrinsics that are extensions to the C and C++ Standards.
To use these intrinsics, your source file must contain #include <arm_compat.h>.
It contains the following sections:
• 4.1 __breakpoint intrinsic on page 4-163.
• 4.2 __current_pc intrinsic on page 4-164.
• 4.3 __current_sp intrinsic on page 4-165.
• 4.4 __disable_fiq intrinsic on page 4-166.
• 4.5 __disable_irq intrinsic on page 4-167.
• 4.6 __enable_fiq intrinsic on page 4-168.
• 4.7 __enable_irq intrinsic on page 4-169.
• 4.8 __force_stores intrinsic on page 4-170.
• 4.9 __memory_changed intrinsic on page 4-171.
• 4.10 __schedule_barrier intrinsic on page 4-172.
• 4.11 __semihost intrinsic on page 4-173.
• 4.12 __vfp_status intrinsic on page 4-175.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-162
Non-Confidential
4 Compiler-specific Intrinsics
4.1 __breakpoint intrinsic
Syntax
void __breakpoint(int val)
Where:
val
is a compile-time constant integer whose range is:
0 ... 65535
if you are compiling source as ARM code
0 ... 255
if you are compiling source as Thumb code.
Errors
The __breakpoint intrinsic is not available when compiling for a target that does not support the BKPT
instruction. The compiler generates an error in this case.
Example
void func(void)
{
...
__breakpoint(0xF02C);
...
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-163
Non-Confidential
4 Compiler-specific Intrinsics
4.2 __current_pc intrinsic
Syntax
unsigned int __current_pc(void)
Return value
The __current_pc intrinsic returns the current value of the program counter at the point in the program
where the intrinsic is used.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-164
Non-Confidential
4 Compiler-specific Intrinsics
4.3 __current_sp intrinsic
Syntax
unsigned int __current_sp(void)
Return value
The __current_sp intrinsic returns the current value of the stack pointer at the point in the program
where the intrinsic is used.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-165
Non-Confidential
4 Compiler-specific Intrinsics
4.4 __disable_fiq intrinsic
Syntax
int __disable_fiq(void)
Usage
int __disable_fiq(void); disables fast interrupts and returns the value the FIQ interrupt mask has in
the PSR before disabling interrupts.
Return value
int __disable_fiq(void); returns the value the FIQ interrupt mask has in the PSR before disabling
FIQ interrupts.
Restrictions
The __disable_fiq intrinsic can only be executed in privileged modes, that is, in non-user modes. In
User mode this intrinsic does not change the interrupt flags in the CPSR.
Example
void foo(void)
{
int was_masked = __disable_fiq();
/* ... */
if (!was_masked)
__enable_fiq();
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-166
Non-Confidential
4 Compiler-specific Intrinsics
4.5 __disable_irq intrinsic
Syntax
int __disable_irq(void)
Usage
int __disable_irq(void); disables interrupts and returns the value the IRQ interrupt mask has in the
PSR before disabling interrupts.
Return value
int __disable_irq(void); returns the value the IRQ interrupt mask has in the PSR before disabling
IRQ interrupts.
Example
void foo(void)
{
int was_masked = __disable_irq();
/* ... */
if (!was_masked)
__enable_irq();
}
Restrictions
The __disable_irq intrinsic can only be executed in privileged modes, that is, in non-user modes. In
User mode this intrinsic does not change the interrupt flags in the CPSR.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-167
Non-Confidential
4 Compiler-specific Intrinsics
4.6 __enable_fiq intrinsic
Syntax
void __enable_fiq(void)
Restrictions
The __enable_fiq intrinsic can only be executed in privileged modes, that is, in non-user modes. In
User mode this intrinsic does not change the interrupt flags in the CPSR.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-168
Non-Confidential
4 Compiler-specific Intrinsics
4.7 __enable_irq intrinsic
Syntax
void __enable_irq(void)
Restrictions
The __enable_irq intrinsic can only be executed in privileged modes, that is, in non-user modes. In
User mode this intrinsic does not change the interrupt flags in the CPSR.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-169
Non-Confidential
4 Compiler-specific Intrinsics
4.8 __force_stores intrinsic
Syntax
void __force_stores(void)
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-170
Non-Confidential
4 Compiler-specific Intrinsics
4.9 __memory_changed intrinsic
Syntax
void __memory_changed(void)
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-171
Non-Confidential
4 Compiler-specific Intrinsics
4.10 __schedule_barrier intrinsic
Syntax
void __schedule_barrier(void)
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-172
Non-Confidential
4 Compiler-specific Intrinsics
4.11 __semihost intrinsic
Syntax
int __semihost(int val, const void *ptr)
Where:
val
Is the request code for the semihosting request.
ptr
Is a pointer to an argument/result block.
Return value
The results of semihosting calls are passed either as an explicit return value or as a pointer to a data
block.
Usage
Use this intrinsic from C or C++ to generate the appropriate semihosting call for your target and
instruction set:
SVC 0x123456
In ARM state, excluding M-profile architectures.
SVC 0xAB
In Thumb state, excluding M-profile architectures. This behavior is not guaranteed on all debug
targets from ARM or from third parties.
HLT 0xF000
In ARM state, excluding M-profile architectures.
HLT 0x3C
In Thumb state, excluding M-profile architectures.
BKPT 0xAB
For M-profile architectures (Thumb only).
Implementation
For ARM processors that are not Cortex-M profile, semihosting is implemented using the SVC or HLT
instruction. For Cortex M-profile processors, semihosting is implemented using the BKPT instruction.
To use HLT-based semihosting, you must define the pre-processor macro __USE_HLT_SEMIHOSTING
before #include <arm_compat.h>. By default, ARM Compiler emits SVC instructions rather than HLT
instructions for semihosting calls. If you define this macro, __USE_HLT_SEMIHOSTING, then ARM
Compiler emits HLT instructions rather than SVC instructions for semihosting calls.
The presence of this macro, __USE_HLT_SEMIHOSTING, does not affect the M-profile architectures which
still use BKPT for semihosting.
Example
char buffer[100];
...
void foo(void)
{
__semihost(0x01, (const void *)buffer);
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-173
Non-Confidential
4 Compiler-specific Intrinsics
4.11 __semihost intrinsic
Compiling this code with the option -mthumb shows the generated SVC instruction:
foo:
...
MOVW r0, :lower16:buffer
MOVT r0, :upper16:buffer
...
SVC #0xab
...
buffer:
.zero 100
.size buffer, 100
Related information
Using the C and C++ libraries with an application in a semihosting environment.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-174
Non-Confidential
4 Compiler-specific Intrinsics
4.12 __vfp_status intrinsic
Syntax
unsigned int __vfp_status(unsigned int mask, unsigned int flags)
Usage
Use this intrinsic to read or modify the flags in FPSCR.
The intrinsic returns the value of FPSCR, unmodified, if mask and flags are 0.
You can clear, set, or toggle individual flags in FPSCR using the bits in mask and flags, as shown in the
following table. The intrinsic returns the modified value of FPSCR if mask and flags are not both 0.
Note
If you want to read or modify only the exception flags in FPSCR, then ARM recommends that you use
the standard C99 features in <fenv.h>.
Errors
The compiler generates an error if you attempt to use this intrinsic when compiling for a target that does
not have VFP.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 4-175
Non-Confidential
Chapter 5
Compiler-specific Pragmas
Summarizes the ARM compiler-specific pragmas that are extensions to the C and C++ Standards.
It contains the following sections:
• 5.1 #pragma clang system_header on page 5-177.
• 5.2 #pragma clang diagnostic on page 5-178.
• 5.3 #pragma clang section on page 5-180.
• 5.4 #pragma once on page 5-182.
• 5.5 #pragma pack(...) on page 5-183.
• 5.6 #pragma unroll[(n)], #pragma unroll_completely on page 5-185.
• 5.7 #pragma weak symbol, #pragma weak symbol1 = symbol2 on page 5-186.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-176
Non-Confidential
5 Compiler-specific Pragmas
5.1 #pragma clang system_header
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-177
Non-Confidential
5 Compiler-specific Pragmas
5.2 #pragma clang diagnostic
This pragma sets the diagnostic message specified by name to warning severity.
This pragma sets the diagnostic message specified by name to error severity.
This pragma sets the diagnostic message specified by name to fatal error severity. Fatal error causes
compilation to fail without processing the rest of the file.
#pragma clang diagnostic push saves the current pragma diagnostic state so that it can restored later.
#pragma clang diagnostic pop restores the diagnostic state that was previously saved using #pragma
clang diagnostic push.
Using pragmas, you can suppress or change the severity of these diagnostic messages for individual
functions.
For foo1(), the current pragma diagnostic state is pushed to the stack and #pragma clang diagnostic
ignored suppresses the message. The diagnostic message is then re-enabled by #pragma clang
diagnostic pop.
For foo2(), the diagnostic message is not suppressed because the original pragma diagnostic state has
been restored.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-178
Non-Confidential
5 Compiler-specific Pragmas
5.2 #pragma clang diagnostic
For foo3(), the message is initially suppressed by the preceding #pragma clang diagnostic ignored
"-Wmultichar", however, the message is then re-enabled as an error, using #pragma clang
diagnostic error "-Wmultichar". The compiler therefore reports an error in foo3().
For foo4(), the pragma diagnostic state is restored to the state saved by the preceding #pragma clang
diagnostic push. This state therefore includes #pragma clang diagnostic ignored "-Wmultichar"
and therefore the compiler does not report a warning in foo4().
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmultichar"
void foo1( void )
{
/* Here we do not expect a diagnostic message, because it is suppressed by #pragma clang
diagnostic ignored "-Wmultichar". */
char c = (char) 'ab';
}
#pragma clang diagnostic pop
Diagnostic messages use the pragma state that is present at the time they are generated. If you use
pragmas to control a diagnostic message in your code, you must be aware of when, in the compilation
process, that diagnostic message is generated.
If a diagnostic message for a function, functionA, is only generated after all the functions have been
processed, then the compiler controls this diagnostic message using the pragma diagnostic state that is
present after processing all the functions. This diagnostic state might be different from the diagnostic
state immediately before or within the definition of functionA.
Related references
1.71 -W on page 1-104.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-179
Non-Confidential
5 Compiler-specific Pragmas
5.3 #pragma clang section
Syntax
#pragma clang section [section_type_list]
Where:
section_type_list
specifies an optional list of section names to be used for subsequent functions, global variables,
or static variables. The syntax of section_type_list is:
section_type="name"[ section_type="name"]
You can revert to the default section name by specifying an empty string, "", for name.
Valid section types are:
• bss.
• data.
• rodata.
• text.
Usage
Use #pragma clang section [section_type_list] to place functions and variables in separate
named sections. You can then use the scatter-loading description file to locate these at a particular
address in memory.
• If you specify a section name with _attribute_((section("myname"))), then the attribute name
has priority over any applicable section name that you specify with #pragma clang section.
• #pragma clang section has priority over the -ffunction-section and -fdata-section
command-line options.
• Global variables, including basic types, arrays, and struct that are initialized to zero are placed in
the .bss section. For example, int x = 0;.
• armclang does not try to infer the type of section from the name. For example, assigning a
section .bss.mysec does not mean it is placed in a .bss section.
• If you specify the -ffunction-section and -fdata-section command-line options, then each
global variable is in a unique section.
Example
int x1 = 5; // Goes in .data section (default)
int y1; // Goes in .bss section (default)
const int z1 = 42; // Goes in .rodata section (default)
char *s1 = "abc1"; // s1 goes in .data section (default). String "abc1" goes
in .conststring section.
#pragma clang section rodata="" // Use default name for rodata section.
int x3 = 5; // Goes in myData section.
int y3; // Goes in myBss section.
const int z3 = 42; // Goes in .rodata section (default).
char *s3 = "abc3"; // s3 goes in myData section. String "abc3" goes
in .conststring section.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-180
Non-Confidential
5 Compiler-specific Pragmas
5.3 #pragma clang section
}
#pragma clang section bss="" data="" text="" // Use default name for bss, data, and text
sections.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-181
Non-Confidential
5 Compiler-specific Pragmas
5.4 #pragma once
Example
The following example shows the placement of a #ifndef guard around the body of the file, with a
#define of the guard variable after the #ifndef.
#ifndef FILE_H
#define FILE_H
#pragma once // optional
... body of the header file ...
#endif
The #pragma once is marked as optional in this example. This is because the compiler recognizes the
#ifndef header guard coding and skips subsequent includes even if #pragma once is absent.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-182
Non-Confidential
5 Compiler-specific Pragmas
5.5 #pragma pack(...)
Note
This pragma is a GNU compiler extension that the ARM compiler supports.
Syntax
#pragma pack([n])
#pragma pack(push[,n])
#pragma pack(pop)
Where:
n
Is the alignment in bytes, valid alignment values are 1, 2, 4, and 8. If omitted, sets the alignment
to the one that was in effect when compilation started.
push[,n]
Pushes the current alignment setting on an internal stack and then optionally sets the new
alignment.
pop
Restores the alignment setting to the one saved at the top of the internal stack, then removes that
stack entry.
Note
#pragma pack([n]) does not influence this internal stack. Therefore, it is possible to have
#pragma pack(push) followed by multiple #pragma pack([n]) instances, then finalized by a
single #pragma pack(pop).
Default
The default is the alignment that was in effect when compilation started.
Example
This example shows how pack(2) aligns integer variable b to a 2-byte boundary.
typedef struct
{
char a;
int b;
} S;
#pragma pack(2)
typedef struct
{
char a;
int b;
} SP;
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-183
Non-Confidential
5 Compiler-specific Pragmas
5.5 #pragma pack(...)
0 1 2 3
a padding
4 5 6 7
b b b b
Note
In this layout, x denotes one byte of padding.
SP is a 6-byte structure. There is no padding after b.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-184
Non-Confidential
5 Compiler-specific Pragmas
5.6 #pragma unroll[(n)], #pragma unroll_completely
Syntax
#pragma unroll
#pragma unroll_completely
#pragma unroll n
#pragma unroll(n)
Where:
n
is an optional value indicating the number of iterations to unroll.
Default
If you do not specify a value for n, the compiler attempts to fully unroll the loop. The compiler can only
fully unroll loops where it can determine the number of iterations.
#pragma unroll_completely will not unroll a loop if the number of iterations is not known at compile
time.
Usage
This pragma only has an effect with optimization level -O2 and higher.
When compiling with -O3, the compiler automatically unrolls loops where it is beneficial to do so. This
pragma can be used to ask the compiler to unroll a loop that has not been unrolled automatically.
#pragma unroll[(n)] can be used immediately before a for loop, a while loop, or a do ... while loop.
Restrictions
This pragma is a request to the compiler to unroll a loop that has not been unrolled automatically. It does
not guarantee that the loop is unrolled.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-185
Non-Confidential
5 Compiler-specific Pragmas
5.7 #pragma weak symbol, #pragma weak symbol1 = symbol2
Example
In the following example, weak_fn is declared as a weak alias of __weak_fn:
extern void weak_fn(int a);
#pragma weak weak_fn = __weak_fn
void __weak_fn(int a)
{
...
}
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 5-186
Non-Confidential
Chapter 6
Other Compiler-specific Features
Summarizes compiler-specific features that are extensions to the C and C++ Standards, such as
predefined macros.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-187
Non-Confidential
6 Other Compiler-specific Features
6.1 ACLE support
Related information
ARM C Language Extensions.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-188
Non-Confidential
6 Other Compiler-specific Features
6.2 Predefined macros
Note
Use -E -dM to see the values of predefined macros.
Macros beginning with __ARM_ are defined by the ARM C Language Extensions 2.0 (ACLE 2.0).
Note
armclang does not fully implement ACLE 2.0.
__ARM_ARCH ver Specifies the version of the target architecture, for example 8.
__ARM_ARCH_EXT_IDIV__ 1 Set for 32-bit targets only.
Set to 1 if hardware divide instructions are available.
__ARM_ARCH_PROFILE ver Specifies the profile of the target architecture, for example 'A'.
__ARM_BIG_ENDIAN - Set if compiling for a big-endian target.
__ARM_FEATURE_CLZ 1 Set to 1 if the CLZ (count leading zeroes) instruction is supported in
hardware.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-189
Non-Confidential
6 Other Compiler-specific Features
6.2 Predefined macros
__ARM_FEATURE_IDIV 1 Set to 1 if the target supports 32-bit signed and unsigned integer division in
all available instruction sets.
__ARM_FEATURE_FMA 1 Set to 1 if the target supports fused floating-point multiply-accumulate.
__ARM_FEATURE_NUMERIC_MAXMIN 1 Set to 1 if the target supports floating-point maximum and minimum
instructions.
Only available when __ARM_ARCH >= 8.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-190
Non-Confidential
6 Other Compiler-specific Features
6.2 Predefined macros
__ARM_NEON_FP val This is the same as __ARM_FP, except that the bit to indicate double-
precision is not set for AArch32. Double-precision is always set for
AArch64.
__ARM_PCS 1 Set for 32-bit targets only.
Set to 1 if the default procedure calling standard for the translation unit
conforms to the base PCS.
__ARM_SIZEOF_MINIMAL_ENUM value Specifies the size of the minimal enumeration type. Set to either 1 or 4
depending on whether -fshort-enums is specified or not.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-191
Non-Confidential
6 Other Compiler-specific Features
6.2 Predefined macros
__arm__ 1 Defined when targeting the A32 or T32 instruction sets with AArch32
targets, for example --target=arm-arm-none-eabi.
See also __aarch64__.
__aarch64__ 1 Defined when targeting the A64 instruction set with --target=aarch64-
arm-none-eabi.
See also __arm__.
__cplusplus ver Defined when compiling C++ code, and set to a value that identifies the
targeted C++ standard. For example, when compiling with -xc++ -
std=gnu++98, the compiler sets this macro to 199711L.
You can use the __cplusplus macro to test whether a file was compiled by
a C compiler or a C++ compiler.
__EXCEPTIONS 1 Defined when compiling a C++ source file with exceptions enabled.
__GNUC__ ver Always set. It is an integer that shows the current major version of the
compatible GCC version.
__GNUC_MINOR__ ver Always set. It is an integer that shows the current minor version of the
compatible GCC version.
__INTMAX_TYPE__ type Always set. Defines the correct underlying type for the intmax_t
typedef.
__NO_INLINE__ 1 Defined if no functions have been inlined. The macro is always defined with
optimization level -O0 or if the -fno-inline option is specified.
__OPTIMIZE__ 1 Defined when -O1, -O2, -O3, -Ofast, -Oz, or -Os is specified.
__PTRDIFF_TYPE__ type Always set. Defines the correct underlying type for the ptrdiff_t
typedef.
__SIZE_TYPE__ type Always set. Defines the correct underlying type for the size_t typedef.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-192
Non-Confidential
6 Other Compiler-specific Features
6.2 Predefined macros
__UINTMAX_TYPE__ type Always set. Defines the correct underlying type for the uintmax_t
typedef.
__VERSION__ ver Always set. A string that shows the underlying Clang version.
__WCHAR_TYPE__ type Always set. Defines the correct underlying type for the wchar_t typedef.
__WINT_TYPE__ type Always set. Defines the correct underlying type for the wint_t typedef.
Related references
1.69 --version_number on page 1-102.
1.63 -std on page 1-95.
1.58 -O on page 1-89.
1.64 --target on page 1-97.
1.43 -marm on page 1-68.
1.54 -mthumb on page 1-85.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-193
Non-Confidential
6 Other Compiler-specific Features
6.3 Inline functions
The linker is able to apply some degree of function inlining to short functions.
Note
The default semantic rules for C-source code follow C99 rules. For inlining, it means that when you
suggest a function is inlined, the compiler expects to find another, non-qualified, version of the function
elsewhere in the code, to use when it decides not to inline. If the compiler cannot find the non-qualified
version, it fails with the following error:
"Error: L6218E: Undefined symbol <symbol> (referred from <file>)".
Related references
2.8 __inline on page 2-119.
1.63 -std on page 1-95.
3.2 __attribute__((always_inline)) function attribute on page 3-125.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-194
Non-Confidential
6 Other Compiler-specific Features
6.4 Half-precision floating-point number format
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
S E T
Where:
S (bit[15]): Sign bit
E (bits[14:10]): Biased exponent
T (bits[9:0]): Mantissa.
Note
See the ARM C Language Extensions for more information.
Related information
ARM C Language Extensions.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-195
Non-Confidential
6 Other Compiler-specific Features
6.5 TT instruction intrinsics
TT intrinsics
The following table describes the TT intrinsics that are available when __ARM_FEATURE_CMSE is set to
either 1 or 3:
Intrinsic Description
cmse_address_info_t cmse_TT(void Generates a TT instruction.
*p)
cmse_address_info_t Generates a TT instruction. The argument p can be any function pointer type.
cmse_TT_fptr(p)
cmse_address_info_t Generates a TT instruction with the T flag. The argument p can be any function pointer
cmse_TTT_fptr(p) type.
When __ARM_BIG_ENDIAN is not set, the result of the intrinsics is returned in the following C type:
typedef union {
struct cmse_address_info {
unsigned mpu_region:8;
unsigned :8;
unsigned mpu_region_valid:1;
unsigned :1;
unsigned read_ok:1;
unsigned readwrite_ok:1;
unsigned :12;
} flags;
unsigned value;
} cmse_address_info_t;
When __ARM_BIG_ENDIAN is set, the bit-fields in the type are reversed such that they have the same bit-
offset as little-endian systems following the rules specified by Procedure Call Standard for the ARM®
Architecture.
Intrinsic Description
cmse_address_info_t Generates a TT instruction with the A flag.
cmse_TTA(void *p)
cmse_address_info_t Generates a TT instruction with the A flag. The argument p can be any function pointer
cmse_TTA_fptr(p) type.
cmse_address_info_t Generates a TT instruction with the T and A flag.
cmse_TTAT(void *p)
cmse_address_info_t Generates a TT instruction with the T and A flag. The argument p can be any function
cmse_TTAT_fptr(p) pointer type.
When __ARM_BIG_ENDIAN is not set, the result of the intrinsics is returned in the following C type:
typedef union {
struct cmse_address_info {
unsigned mpu_region:8;
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-196
Non-Confidential
6 Other Compiler-specific Features
6.5 TT instruction intrinsics
unsigned sau_region:8;
unsigned mpu_region_valid:1;
unsigned sau_region_valid:1;
unsigned read_ok:1;
unsigned readwrite_ok:1;
unsigned nonsecure_read_ok:1;
unsigned nonsecure_readwrite_ok:1;
unsigned secure:1;
unsigned idau_region_valid:1;
unsigned idau_region:8;
} flags;
unsigned value;
} cmse_address_info_t;
When __ARM_BIG_ENDIAN is set, the bit-fields in the type are reversed such that they have the same bit-
offset as little-endian systems following the rules specified by Procedure Call Standard for the ARM®
Architecture.
In the Secure state, the TT instruction returns the Security Attribute Unit (SAU) and Implementation
Defined Attribute Unit (IDAU) configuration and recognizes the A flag.
The address range check intrinsic fails if the range crosses any MPU region boundary.
The flags parameter of the address range check consists of a set of values defined by the macros shown
in the following table:
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-197
Non-Confidential
6 Other Compiler-specific Features
6.5 TT instruction intrinsics
(continued)
The address range check intrinsic returns p on a successful check, and NULL on a failed check. The check
fails if any other value is returned that is not one of those listed in the table, or is not a combination of
those listed.
ARM recommends that you use the returned pointer to access the checked memory range. This generates
a data dependency between the checked memory and all its subsequent accesses and prevents these
accesses from being scheduled before the check.
The following intrinsic is defined when the __ARM_FEATURE_CMSE macro is set to 1:
Intrinsic Description
cmse_check_pointed_object(p, f) Returns the same value as
cmse_check_address_range(p, sizeof(*p), f)
ARM recommends that the return type of this intrinsic is identical to the type of parameter p.
Related references
6.2 Predefined macros on page 6-189.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-198
Non-Confidential
6 Other Compiler-specific Features
6.6 Non-secure function pointer intrinsics
Intrinsic Description
cmse_nsfptr_create(p) Returns the value of p with its LSB cleared. The argument p can be any function pointer type.
ARM recommends that the return type of this intrinsic is identical to the type of its argument.
cmse_is_nsfptr(p) Returns non-zero if p has LSB unset, zero otherwise. The argument p can be any function pointer type.
Example
The following example shows how to use these intrinsics:
#include <arm_cmse.h>
typedef void __attribute__((cmse_nonsecure_call)) nsfunc(void);
void default_callback(void) { … }
void call_callback(void) {
if (cmse_is_nsfptr(fp)) fp(); // non-secure function call
else ((void (*)(void)) fp)(); // normal function call
}
Related references
3.3 __attribute__((cmse_nonsecure_call)) function attribute on page 3-126.
3.4 __attribute__((cmse_nonsecure_entry)) function attribute on page 3-127.
Related information
Building Secure and Non-secure Images Using ARMv8-M Security Extensions.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 6-199
Non-Confidential
Chapter 7
Standard C Implementation Definition
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-200
Non-Confidential
7 Standard C Implementation Definition
7.1 Implementation Definition
Related references
7.2 Translation on page 7-202.
7.3 Translation limits on page 7-203.
7.4 Environment on page 7-205.
7.5 Identifiers on page 7-207.
7.6 Characters on page 7-208.
7.7 Integers on page 7-210.
7.8 Floating-point on page 7-211.
7.9 Arrays and pointers on page 7-212.
7.10 Hints on page 7-213.
7.11 Structures, unions, enumerations, and bitfields on page 7-214.
7.12 Qualifiers on page 7-215.
7.13 Preprocessing directives on page 7-216.
7.14 Library functions on page 7-217.
7.15 Architecture on page 7-222.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-201
Non-Confidential
7 Standard C Implementation Definition
7.2 Translation
7.2 Translation
Describes implementation-defined aspects of the ARM C compiler and C library relating to translation,
as required by the ISO C standard.
How a diagnostic is identified (3.10, 5.1.1.3).
Diagnostic messages that the compiler produces are of the form:
source-file:line-number:char-number: description [diagnostic-flag]
Here:
description
Is a text description of the error.
diagnostic-flag
Is an optional diagnostic flag of the form -Wflag, only for messages that can be
suppressed.
Whether each nonempty sequence of white-space characters other than new-line is retained or
replaced by one space character in translation phase 3 (5.1.1.2).
Each nonempty sequence of white-space characters, other than new-line, is replaced by one
space character.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-202
Non-Confidential
7 Standard C Implementation Definition
7.3 Translation limits
Nesting levels of block. 256 (can be increased using the -fbracket-depth option.)
Nesting levels of parenthesized declarators within a full 256 (can be increased using the -fbracket-depth option.)
declarator.
Nesting levels of parenthesized expressions within a full 256 (can be increased using the -fbracket-depth option.)
expression.
Levels of nested structure or union definitions in a single struct- 256 (can be increased using the -fbracket-depth option.)
declaration-list.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-203
Non-Confidential
7 Standard C Implementation Definition
7.3 Translation limits
Related references
1.9 -fbracket-depth=N on page 1-31.
7.15 Architecture on page 7-222.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-204
Non-Confidential
7 Standard C Implementation Definition
7.4 Environment
7.4 Environment
Describes implementation-defined aspects of the ARM C compiler and C library relating to environment,
as required by the ISO C standard.
The mapping between physical source file multibyte characters and the source character set in
translation phase 1 (5.1.1.2).
The compiler interprets the physical source file multibyte characters as UTF-8.
The name and type of the function called at program startup in a freestanding environment
(5.1.2.1).
When linking with microlib, the function main() must be declared to take no arguments and
must not return.
The effect of program termination in a freestanding environment (5.1.2.1).
The function exit() is not supported by microlib and the function main() must not return.
An alternative manner in which the main function can be defined (5.1.2.2.1).
The main function can be defined in one of the following forms:
int main(void)
int main()
int main(int)
int main(int, char **)
int main(int,char **, char **)
The values given to the strings pointed to by the argv argument to main (5.1.2.2.1).
In the generic ARM library the arguments given to main() are the words of the command line
not including input/output redirections, delimited by whitespace, except where the whitespace is
contained in double quotes.
What constitutes an interactive device (5.1.2.3).
What constitutes an interactive device depends on the environment and the _sys_istty
function. The standard I/O streams stdin, stdout, and stderr are assumed to be interactive
devices. They are line-buffered at program startup, regardless of what _sys_istty reports for
them. An exception is if they have been redirected on the command line.
Whether a program can have more than one thread of execution in a freestanding environment
(5.1.2.4).
Depends on the environment. The microlib C library is not thread-safe.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-205
Non-Confidential
7 Standard C Implementation Definition
7.4 Environment
The set of signals, their semantics, and their default handling (7.14).
The <signal.h> header defines the following signals:
The default handling of all recognized signals is to print a diagnostic message and call exit().
Signal values other than SIGFPE, SIGILL, and SIGSEGV that correspond to a computational
exception (7.14.1.1).
No signal values other than SIGFPE, SIGILL, and SIGSEGV correspond to a computational
exception.
Signals for which the equivalent of signal(sig, SIG_IGN); is executed at program startup
(7.14.1.1).
No signals are ignored at program startup.
The set of environment names and the method for altering the environment list used by the getenv
function (7.22.4.6).
The default implementation returns NULL, indicating that no environment information is
available.
The manner of execution of the string by the system function (7.22.4.8).
Depends on the environment. The default implementation of the function uses semihosting.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-206
Non-Confidential
7 Standard C Implementation Definition
7.5 Identifiers
7.5 Identifiers
Describes implementation-defined aspects of the ARM C compiler and C library relating to identifiers,
as required by the ISO C standard.
Which additional multibyte characters may appear in identifiers and their correspondence to
universal character names (6.4.2).
Multibyte characters, whose UTF-8 decoded value falls within one of the ranges in Appendix D
of ISO/IEC 9899:2011 are allowed in identifiers and correspond to the universal character name
with the short identifier (as specified by ISO/IEC 10646) having the same numeric value.
The dollar character $ is allowed in identifiers.
The number of significant initial characters in an identifier (5.2.4.1, 6.4.2).
There is no limit on the number of significant initial characters in an identifier.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-207
Non-Confidential
7 Standard C Implementation Definition
7.6 Characters
7.6 Characters
Describes implementation-defined aspects of the ARM C compiler and C library relating to characters, as
required by the ISO C standard.
The number of bits in a byte (3.6).
The number of bits in a byte is 8.
The values of the members of the execution character set (5.2.1).
The values of the members of the execution character set are all the code points defined by
ISO/IEC 10646.
The unique value of the member of the execution character set produced for each of the standard
alphabetic escape sequences (5.2.2).
Character escape sequences have the following values in the execution character set:
The value of a char object into which has been stored any character other than a member of the
basic execution character set (6.2.5).
The value of a char object into which has been stored any character other than a member of the
basic execution character set is the least significant 8 bits of that character, interpreted as
unsigned.
Which of signed char or unsigned char has the same range, representation, and behavior as plain
char (6.2.5, 6.3.1.1).
Data items of type char are unsigned by default. The type unsigned char has the same range,
representation, and behavior as char.
The mapping of members of the source character set (in character constants and string literals) to
members of the execution character set (6.4.4.4, 5.1.1.2).
The execution character set is identical to the source character set.
The value of an integer character constant containing more than one character or containing a
character or escape sequence that does not map to a single-byte execution character (6.4.4.4).
In C all character constants have type int. Up to four characters of the constant are represented
in the integer value. The last character in the constant occupies the lowest-order byte of the
integer value. Up to three preceding characters are placed at higher-order bytes. Unused bytes
are filled with the NUL (\0) character.
The value of a wide character constant containing more than one multibyte character or a single
multibyte character that maps to multiple members of the extended execution character set, or
containing a multibyte character or escape sequence not represented in the extended execution
character set (6.4.4.4).
If a wide character constant contains more than one multibyte character, all but the last such
character are ignored.
The current locale used to convert a wide character constant consisting of a single multibyte
character that maps to a member of the extended execution character set into a corresponding
wide character code (6.4.4.4).
Mapping of wide character constants to the corresponding wide character code is locale
independent.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-208
Non-Confidential
7 Standard C Implementation Definition
7.6 Characters
Whether differently-prefixed wide string literal tokens can be concatenated and, if so, the
treatment of the resulting multibyte character sequence (6.4.5).
Differently prefixed wide string literal tokens cannot be concatenated.
The current locale used to convert a wide string literal into corresponding wide character codes
(6.4.5).
Mapping of the wide characters in a wide string literal into the corresponding wide character
codes is locale independent.
The value of a string literal containing a multibyte character or escape sequence not represented in
the execution character set (6.4.5).
The compiler does not check if the value of a multibyte character or an escape sequence is a
valid ISO/IEC 10646 code point. Such a value is encoded like the values of the valid members
of the execution character set, according to the kind of the string literal (character or wide
character).
The encoding of any of wchar_t, char16_t, and char32_t where the corresponding standard
encoding macro (__STDC_ISO_10646__, __STDC_UTF_16__, or __STDC_UTF_32__) is not defined
(6.10.8.2).
The symbol __STDC_ISO_10646__ is not defined. Nevertheless every character in the Unicode
required set, when stored in an object of type wchar_t, has the same value as the short identifier
of that character.
The symbols __STDC_UTF_16__ and __STDC_UTF_32__ are defined.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-209
Non-Confidential
7 Standard C Implementation Definition
7.7 Integers
7.7 Integers
Describes implementation-defined aspects of the ARM C compiler and C library relating to integers, as
required by the ISO C standard.
Any extended integer types that exist in the implementation (6.2.5).
No extended integer types exist in the implementation.
Whether signed integer types are represented using sign and magnitude, two’s complement, or
ones’ complement, and whether the extraordinary value is a trap representation or an ordinary
value (6.2.6.2).
Signed integer types are represented using two's complement with no padding bits. There is no
extraordinary value.
The rank of any extended integer type relative to another extended integer type with the same
precision (6.3.1.1).
No extended integer types exist in the implementation.
The result of, or the signal raised by, converting an integer to a signed integer type when the value
cannot be represented in an object of that type (6.3.1.3).
When converting an integer to a N-bit wide signed integer type and the value cannot be
represented in the destination type, the representation of the source operand is truncated to N-
bits and the resulting bit patters is interpreted a value of the destination type. No signal is raised.
The results of some bitwise operations on signed integers (6.5).
In the bitwise right shift E1 >> E2, if E1 has a signed type and a negative value, the value of the
result is the integral part of the quotient of E1 / 2^E2, except that shifting the value –1 yields
result –1.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-210
Non-Confidential
7 Standard C Implementation Definition
7.8 Floating-point
7.8 Floating-point
Describes implementation-defined aspects of the ARM C compiler and C library relating to floating-
point operations, as required by the ISO C standard.
The accuracy of the floating-point operations and of the library functions in <math.h> and
<complex.h> that return floating-point results (5.2.4.2.2).
Floating-point quantities are stored in IEEE format:
• float values are represented by IEEE single-precision values
• double and long double values are represented by IEEE double-precision values.
The accuracy of the conversions between floating-point internal representations and string
representations performed by the library functions in <stdio.h>, <stdlib.h>, and <wchar.h>
(5.2.4.2.2).
The accuracy of the conversions between floating-point internal representations and string
representations performed by the library functions in <stdio.h>, <stdlib.h>, and <wchar.h>
is unknown.
The rounding behaviors characterized by non-standard values of FLT_ROUNDS (5.2.4.2.2).
ARM Compiler does not define non-standard values for FLT_ROUNDS.
The evaluation methods characterized by non-standard negative values of FLT_EVAL_METHOD
(5.2.4.2.2).
ARM Compiler does not define non-standard values for FLT_EVAL_METHOD.
The direction of rounding when an integer is converted to a floating-point number that cannot
exactly represent the original value (6.3.1.4).
The direction of rounding when an integer is converted to a floating point number is "round to
nearest even".
The direction of rounding when a floating-point number is converted to a narrower floating-point
number (6.3.1.5).
When a floating-point number is converted to a different floating-point type and the value is
within the range of the destination type, but cannot be represented exactly, the rounding mode is
"round to nearest even", by default.
How the nearest representable value or the larger or smaller representable value immediately
adjacent to the nearest representable value is chosen for certain floating constants (6.4.4.2).
When a floating-point literal is converted to a floating-point value, the rounding mode is "round
to nearest even".
Whether and how floating expressions are contracted when not disallowed by the FP_CONTRACT
pragma (6.5).
If –ffp-mode=fast, -ffast-math, or -ffp-contract=fast options are in effect, a floating-
point expression can be contracted.
The default state for the FENV_ACCESS pragma (7.6.1).
The default state of the FENV_ACCESS pragma is OFF. The state ON is not supported.
Additional floating-point exceptions, rounding classifications, and their macro names (7.6, 7.12),
modes, environments, and the default state for the FP_CONTRACT pragma (7.12.2).
No additional floating-point exceptions, rounding classifications, modes, or environments are
defined.
The default state of FP_CONTRACT pragma is OFF.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-211
Non-Confidential
7 Standard C Implementation Definition
7.9 Arrays and pointers
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-212
Non-Confidential
7 Standard C Implementation Definition
7.10 Hints
7.10 Hints
Describes implementation-defined aspects of the ARM C compiler and C library relating to registers, as
required by the ISO C standard.
The extent to which suggestions made by using the register storage-class specifier are effective
(6.7.1).
The register storage-class specifier is ignored as a means to control how fast the access to an
object is. For example, an object might be allocated in register or allocated in memory
regardless of whether it is declared with register storage-class.
The extent to which suggestions made by using the inline function specifier are effective (6.7.4).
The inline function specifier is ignored as a means to control how fast the calls to the function
are made. For example, a function might be inlined or not regardless of whether it is declared
inline.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-213
Non-Confidential
7 Standard C Implementation Definition
7.11 Structures, unions, enumerations, and bitfields
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-214
Non-Confidential
7 Standard C Implementation Definition
7.12 Qualifiers
7.12 Qualifiers
Describes implementation-defined aspects of the ARM C compiler and C library relating to qualifiers, as
required by the ISO C standard.
What constitutes an access to an object that has volatile-qualified type (6.7.3).
Modifications of an object that has a volatile qualified type constitutes an access to that object.
Value computation of an lvalue expression with a volatile qualified type constitutes an access to
the corresponding object, even when the value is discarded.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-215
Non-Confidential
7 Standard C Implementation Definition
7.13 Preprocessing directives
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-216
Non-Confidential
7 Standard C Implementation Definition
7.14 Library functions
The representation of the floating-points status flags stored by the fegetexceptflag function
(7.6.2.2).
The fegetexceptflag function stores the floating-point status flags as a bit set as follows:
• Bit 0 (0x01) is for the Invalid Operation exception.
• Bit 1 (0x02) is for the Divide by Zero exception.
• Bit 2 (0x04) is for the Overflow exception.
• Bit 3 (0x08) is for the Underflow exception.
• Bit 4 (0x10) is for the Inexact Result exception.
Whether the feraiseexcept function raises the Inexact floating-point exception in addition to the
Overflow or Underflow floating-point exception (7.6.2.3).
The feraiseexcept function does not raise by itself the Inexact floating-point exception when
it raises either an Overflow or Underflow exception.
Strings other than "C" and "" that can be passed as the second argument to the setlocale function
(7.11.1.1).
What other strings can be passed as the second argument to the setlocale function depends on
which __use_X_ctype symbol is imported (__use_iso8859_ctype, __use_sjis_ctype, or
__use_utf8_ctype), and on user-defined locales.
The types defined for float_t and double_t when the value of the FLT_EVAL_METHOD macro is less
than 0 (7.12).
The types defined for float_t and double_t are float and double, respectively, for all the
supported values of FLT_EVAL_METHOD.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-217
Non-Confidential
7 Standard C Implementation Definition
7.14 Library functions
Domain errors for the mathematics functions, other than those required by this International
Standard (7.12.1).
The following functions return additional domain errors under the specified conditions (the
function name refers to all the variants of the function. For example, the acos entry applies to
acos, ascof, and acosl functions):
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-218
Non-Confidential
7 Standard C Implementation Definition
7.14 Library functions
The values returned by the mathematics functions on domain errors or pole errors (7.12.1).
See previous table.
The values returned by the mathematics functions on underflow range errors, whether errno is set
to the value of the macro ERANGE when the integer expression math_errhandling & MATH_ERRNO is
nonzero, and whether the Underflow floating-point exception is raised when the integer expression
math_errhandling & MATH_ERREXCEPT is nonzero. (7.12.1).
On underflow, the mathematics functions return 0.0, the errno is set to ERANGE, and the
Underflow and Inexact exceptions are raised.
Whether a domain error occurs or zero is returned when an fmod function has a second argument
of zero (7.12.10.1).
When the second argument of fmod is zero, a domain error occurs.
Whether a domain error occurs or zero is returned when a remainder function has a second
argument of zero (7.12.10.2).
When the second argument of the remainder function is zero, a domain error occurs and the
function returns NaN.
The base-2 logarithm of the modulus used by the remquo functions in reducing the quotient
(7.12.10.3).
The base-2 logarithm of the modulus used by the remquo functions in reducing the quotient is 4.
Whether a domain error occurs or zero is returned when a remquo function has a second
argument of zero (7.12.10.3).
When the second argument of the remquo function is zero, a domain error occurs.
Whether the equivalent of signal(sig, SIG_DFL); is executed prior to the call of a signal handler,
and, if not, the blocking of signals that is performed (7.14.1.1).
The equivalent of signal(sig, SIG_DFL) is executed before the call to a signal handler.
The null pointer constant to which the macro NULL expands (7.19).
The macro NULL expands to 0.
Whether the last line of a text stream requires a terminating new-line character (7.21.2).
The last line of text stream does not require a terminating new-line character.
Whether space characters that are written out to a text stream immediately before a new-line
character appear when read in (7.21.2).
Space characters, written out to a text stream immediately before a new-line character, appear
when read back.
The number of null characters that may be appended to data written to a binary stream (7.21.2).
No null characters are appended at the end of a binary stream.
Whether the file position indicator of an append-mode stream is initially positioned at the
beginning or end of the file (7.21.3).
The file position indicator of an append-mode stream is positioned initially at the end of the file.
Whether a write on a text stream causes the associated file to be truncated beyond that point
(7.21.3).
A write to a text stream causes the associated file to be truncated beyond the point where the
write occurred if this is the behavior of the device category of the file.
The characteristics of file buffering (7.21.3).
The C Library supports unbuffered, fully buffered, and line buffered streams.
Whether a zero-length file actually exists (7.21.3).
A zero-length file exists, even if no characters are written by an output stream.
The rules for composing valid file names (7.21.3).
Valid file names depend on the execution environment.
Whether the same file can be simultaneously open multiple times (7.21.3).
A file can be opened many times for reading, but only once for writing or updating.
The nature and choice of encodings used for multibyte characters in files (7.21.3).
The character input and output functions on wide-oriented streams interpret the multibyte
characters in the associated files according to the current chosen locale.
The effect of the remove function on an open file (7.21.4.1).
Depends on the environment.
The effect if a file with the new name exists prior to a call to the rename function (7.21.4.2).
Depends on the environment.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-219
Non-Confidential
7 Standard C Implementation Definition
7.14 Library functions
Whether an open temporary file is removed upon abnormal program termination (7.21.4.3).
Depends on the environment.
Which changes of mode are permitted (if any), and under what circumstances (7.21.5.4)
No changes of mode are permitted.
The style used to print an infinity or NaN, and the meaning of any n-char or n-wchar sequence
printed for a NaN (7.21.6.1, 7.29.2.1).
A double argument to the printf family of functions, representing an infinity is converted to
[-]inf. A double argument representing a NaN is converted to [-]nan. The F conversion
specifier, produces [-]INF or [-]NAN, respectively.
The output for %p conversion in the fprintf or fwprintf function (7.21.6.1, 7.29.2.1).
The fprintf and fwprintf functions print %p arguments in lowercase hexadecimal format as if
a precision of 8 (16 for 64-bit) had been specified. If the variant form (%#p) is used, the number
is preceded by the character @.
Note
Using the # character with the p format specifier is undefined behavior in C11. armclang issues
a warning.
The interpretation of a - character that is neither the first nor the last character, nor the second
where a ^ character is the first, in the scanlist for %[ conversion in the fscanf or fwscanf function
(7.21.6.2, 7.29.2.1).
fscanf and fwscanf always treat the character - in a %...[...] argument as a literal character.
The set of sequences matched by a %p conversion and the interpretation of the corresponding input
item in the fscanf or fwscanf function (7.21.6.2, 7.29.2.2).
fscanf and fwscanf treat %p arguments exactly the same as %x arguments.
The value to which the macro errno is set by the fgetpos, fsetpos, or ftell functions on failure
(7.21.9.1, 7.21.9.3, 7.21.9.4).
On failure, the functions fgetpos, fsetpos, and ftell set the errno to EDOM.
The meaning of any n-char or n-wchar sequence in a string representing a NaN that is converted
by the strtod, strtof, strtold, wcstod, wcstof, or wcstold function (7.22.1.3, 7.29.4.1.1).
Any n-char or n-wchar sequence in a string, representing a NaN, that is converted by the
strtod, strtof, strtold, wcstod, wcstof, or wcstold functions, is ignored.
Whether or not the strtod, strtof, strtold, wcstod, wcstof, or wcstold function sets errno to
ERANGE when underflow occurs (7.22.1.3, 7.29.4.1.1).
The strtod, strtold, wcstod, wcstof, or wcstold functions set errno to ERANGE when
underflow occurs.
The strtof function sets the errno to ERANGE by default (equivalent to compiling with
-ffp-mode=std) and doesn't, when compiling with -ffp-mode=full or -fno-fast-math.
Whether the calloc, malloc, and realloc functions return a null pointer or a pointer to an
allocated object when the size requested is zero (7.22.3).
If the size of area requested is zero, malloc() and calloc() return a pointer to a zero-size
block.
If the size of area requested is zero, realloc() returns NULL.
Whether open streams with unwritten buffered data are flushed, open streams are closed, or
temporary files are removed when the abort or _Exit function is called (7.22.4.1, 7.22.4.5).
The function _Exit flushes the streams, closes all open files, and removes the temporary files.
The function abort() does not flush the streams and does not remove temporary files.
The termination status returned to the host environment by the abort, exit, _Exit(), or
quick_exit function (7.22.4.1, 7.22.4.4, 7.22.4.5, 7.22.4.7).
The function abort() returns termination status 1 to the host environment. The functions
exit() and _Exit() return the same value as the argument that was passed to them.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-220
Non-Confidential
7 Standard C Implementation Definition
7.14 Library functions
The value returned by the system function when its argument is not a null pointer (7.22.4.8).
The value returned by the system function when its argument is not a null pointer depends on
the environment.
The range and precision of times representable in clock_t and time_t (7.27).
The types clock_t and time_t can represent integers in the range [0, 4294967295].
The local time zone and Daylight Saving Time (7.27.1).
Depends on the environment.
The era for the clock function (7.27.2.1).
Depends on the environment.
The TIME_UTC epoch (7.27.2.5).
TIME_UTC and timespec_get are not implemented.
The replacement string for the %Z specifier to the strftime and wcsftime functions in the "C"
locale (7.27.3.5, 7.29.5.1).
The functions strftime and wcsftime replace %Z with an empty string.
Whether the functions in <math.h> honor the rounding direction mode in an IEC 60559
conformant implementation, unless explicitly specified otherwise (F.10).
ARM Compiler does not declare __STDC_IEC_559__ and does not support Annex F of ISO/IEC
9899:2011.
Related information
The ARM C and C++ Libraries.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-221
Non-Confidential
7 Standard C Implementation Definition
7.15 Architecture
7.15 Architecture
Describes implementation-defined aspects of the ARM C compiler and C library relating to architecture,
as required by the ISO C standard.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-222
Non-Confidential
7 Standard C Implementation Definition
7.15 Architecture
The values or expressions assigned to the macros specified in the headers <float.h>, <limits.h>,
and <stdint.h> (5.2.4.2, 7.20.2, 7.20.3).
Note
If the value column is empty, this means no value is assigned to the corresponding macro.
FLT_EVAL_METHOD 0
FLT_HAS_SUBNORM
DBL_HAS_SUBNORM
LDBL_HAS_SUBNORM
FLT_RADIX 2
FLT_MANT_DIG 24
DBL_MANT_DIG 53
LDBL_MANT_DIG 53
FLT_DECIMAL_DIG
DBL_DECIMAL_DIG
LDBL_DECIMAL_DIG
DECIMAL_DIG 17
FLT_DIG 6
DBL_DIG 15
LDBL_DIG 15
FLT_MIN_EXP (-125)
DBL_MIN_EXP (-1021)
LDBL_MIN_EXP (-1021)
FLT_MIN_10_EXP (-37)
DBL_MIN_10_EXP (-307)
LDBL_MIN_10_EXP (-307)
FLT_MAX_EXP 128
DBL_MAX_EXP 1024
LDBL_MAX_EXP 1024
FLT_MAX_10_EXP 38
DBL_MAX_10_EXP 308
LDBL_MAX_10_EXP 308
FLT_MAX 3.40282347e+38F
DBL_MAX 1.79769313486231571e+308
LDBL_MAX 1.79769313486231571e+308L
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-223
Non-Confidential
7 Standard C Implementation Definition
7.15 Architecture
(continued)
DBL_EPSILON 2.2204460492503131e-16
LDBL_EPSILON 2.2204460492503131e-16L
FLT_MIN 1.175494351e-38F
DBL_MIN 2.22507385850720138e-308
LDBL_MIN 2.22507385850720138e-308L
FLT_TRUE_MIN
DBL_TRUE_MIN
LDBL_TRUE_MIN
SCHAR_MIN (-128)
SCHAR_MAX 127
UCHAR_MAX 255
CHAR_MIN 0
CHAR_MAX 255
MB_LEN_MAX 6
SHRT_MIN (-0x8000)
SHRT_MAX 0x7fff
USHRT_MAX 65535
INT_MIN (~0x7fffffff)
INT_MAX 0x7fffffff
UINT_MAX 0xffffffffU
LONG_MIN (~0x7fffffffL)
LONG_MAX 0x7fffffffL
ULONG_MAX 0xffffffffUL
LLONG_MIN (~0x7fffffffffffffffLL)
LLONG_MAX 0x7fffffffffffffffLL
ULLONG_MAX 0xffffffffffffffffULL
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-224
Non-Confidential
7 Standard C Implementation Definition
7.15 Architecture
INT8_MAX 127
UINT8_MAX 255
INT16_MIN -32768
INT16_MAX 32767
UINT16_MAX 65535
INT32_MIN (~0x7fffffff)
INT32_MAX 2147483647
UINT32_MAX 4294967295u
INT64_MIN (~0x7fffffffffffffffLL)
INT32_MAX 2147483647
UINT32_MAX 4294967295u
INT_LEAST8_MIN -128
INT_LEAST8_MAX 127
UINT_LEAST8_MAX 255
INT_LEAST16_MIN -32768
INT_LEAST16_MAX 32767
UINT_LEAST16_MAX 65535
INT_LEAST32_MIN (~0x7fffffff)
INT_LEAST32_MAX 2147483647
UINT_LEAST32_MAX 4294967295u
INT_LEAST64_MIN (~0x7fffffffffffffffLL)
INT_LEAST64_MAX (9223372036854775807LL)
UINT_LEAST64_MAX (18446744073709551615uLL)
INT_FAST8_MIN (~0x7fffffff)
INT_FAST8_MAX 2147483647
UINT_FAST8_MAX 4294967295u
INT_FAST16_MIN (~0x7fffffff)
INT_FAST16_MAX 2147483647
UINT_FAST16_MAX 4294967295u
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-225
Non-Confidential
7 Standard C Implementation Definition
7.15 Architecture
(continued)
INT_FAST32_MAX 2147483647
UINT_FAST32_MAX 4294967295u
INT_FAST64_MIN (~0x7fffffffffffffffLL)
INT_FAST64_MAX (9223372036854775807LL)
UINT_FAST64_MAX (18446744073709551615uLL)
INTPTR_MIN (~0x7fffffff)
INTPTR_MAX 2147483647
UINTPTR_MAX 4294967295u
INTMAX_MIN (~0x7fffffffffffffffll)
INTMAX_MAX (9223372036854775807ll)
UINTMAX_MAX (18446744073709551615ull)
PTRDIFF_MIN (~0x7fffffff)
PTRDIFF_MAX 2147483647
SIG_ATOMIC_MIN (~0x7fffffff)
SIG_ATOMIC_MAX 2147483647
SIZE_MAX 4294967295u
WCHAR_MIN 0
WCHAR_MAX 0xffffffffU
WINT_MIN (~0x7fffffff)
WINT_MAX 2147483647
The result of attempting to indirectly access an object with automatic or thread storage duration
from a thread other than the one with which it is associated (6.2.4).
Access to automatic or thread storage duration objects from a thread other than the one with
which the object is associated proceeds normally.
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-226
Non-Confidential
7 Standard C Implementation Definition
7.15 Architecture
The number, order, and encoding of bytes in any object (when not explicitly specified in this
International Standard) (6.2.6.1).
Defined in the ARM EABI.
Whether any extended alignments are supported and the contexts in which they are supported,
and valid alignment values other than those returned by an _Alignof expression for fundamental
types, if any (6.2.8).
Alignments, including extended alignments, that are a power of 2 and less than or equal to
0x10000000, are supported.
The value of the result of the sizeof and _Alignof operators (6.5.3.4).
char 1 1
short 2 2
int 4 4
long 4 4
long (64-bit) 8 8
long long 8 8
float 4 4
double 8 8
long double 8 8
ARM 100067_0608_00_en Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved. 7-227
Non-Confidential