Preprocessing assembly code
The C preprocessor must resolve assembly code that contains C directives, for example
#define, before assembling.
By default, armclang uses the assembly code source file suffix to determine whether to run the C preprocessor:
.s(lowercase) suffix indicates assembly code that does not require preprocessing.
.S(uppercase) suffix indicates assembly code that requires preprocessing.
-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,
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
Do not confuse the
directive with the preprocessor
- The preprocessor
#ifdefdirective checks for the presence of preprocessor macros, These macros are defined using the
#definepreprocessor directive or the armclang
- The armclang integrated
.ifdefdirective checks for code symbols. These symbols are defined using labels or the
The preprocessor runs first and performs textual substitutions on the
source code. This stage is when the
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:
Ensure that the assembly code filename has a
armclang --target=arm-arm-none-eabi -march=armv8-a -E test.S
-x assembler-with-cppoption to tell
armclangthat the assembly source file requires preprocessing. This option is useful when you have existing source files with the lowercase extension
armclang --target=arm-arm-none-eabi -march=armv8-a -E -x assembler-with-cpp test.s
-Eoption specifies that
armclangonly executes the preprocessor step.