Keil Logo

Command-line options for preprocessing assembly source code

3.3 Command-line options for preprocessing assembly source code

The functionality of the --cpreproc and --cpreproc_opts command-line options in the version of armasm supplied with Arm® Compiler 6 is different from the options used in earlier versions of armasm to preprocess assembly source code.

If you are using armasm to assemble source code that requires the use of the preprocessor, you must use both the --cpreproc and --cpreproc_opts options together. Also:

  • As a minimum, you must include the armclang options --target and either -mcpu or -march in --cpreproc_opts.
  • The input assembly source must have an upper-case extension .S.

If you have existing source files, which require preprocessing, and that have the lower-case extension .s, then to avoid having to rename the files:

  1. Perform the preprocessing step separately using the armclang -x assembler-with-cpp option.
  2. Assemble the preprocessed file without using the --cpreproc and --cpreproc_opts options.

Example using armclang -x

This example shows the use of the armclang -x option.

armclang --target=aarch64-arm-none-eabi -march=armv8-a -x assembler-with-cpp -E test.s -o test_preproc.s
armasm --cpu=8-A.64 test_preproc.s

Example using armasm --cpreproc_opts

The options to the preprocessor in this example are --cpreproc_opts=--target=arm-arm-none-eabi,-mcpu=cortex-a9,-D,DEF1,-D,DEF2.

armasm --cpu=cortex-a9 --cpreproc --cpreproc_opts=--target=arm-arm-none-eabi,-mcpu=cortex-a9,-D,DEF1,-D,DEF2 -I /path/to/includes1 -I /path/to/includes2 input.S


Ensure that you specify compatible architectures in the armclang options --target, -mcpu or -march, and the armasm --cpu option.
Non-ConfidentialPDF file icon PDF version100068_0615_00_en
Copyright © 2014–2020 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.