4.2 Preprocessing assembly code

The C preprocessor must resolve assembly code that contains C directives, for example #include or #define, before assembling.

By default, armclang uses the assembly code source file suffix to determine whether to run the C preprocessor:

The -x option lets you override the default by specifying the language of the subsequent source files, rather than inferring the language from the file suffix. Specifically, -x assembler-with-cpp indicates that the assembly code contains C directives and armclang must run the C preprocessor. The -x option only applies to input files that follow it on the command line.


Do not confuse the .ifdef assembler directive with the preprocessor #ifdef directive:

  • The preprocessor #ifdef directive checks for the presence of preprocessor macros, These macros are defined using the #define preprocessor directive or the armclang -D command-line option.
  • The armclang integrated assembler .ifdef directive checks for code symbols. These symbols are defined using labels or the .set directive.

The preprocessor runs first and performs textual substitutions on the source code. This stage is when the #ifdef directive is processed. The source code is then passed onto the assembler, when the .ifdef directive is processed.

To preprocess an assembly code source file, do one of the following:


The -E option specifies that armclang only executes the preprocessor step.
Non-ConfidentialPDF file icon PDF versionDUI0773J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.