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 */

int Signal (int value)
{
  if (value>LEVEL) return HIGH; // Comment C
  return LOW + THIS;
}

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

The output from the preprocessor contains:

// #define THIS 99

// Comment A
/* Comment B */

int Signal (int value)
{
  if (value>LEVEL) return 1; // Comment C
  return 0 + THIS;
}

The preprocessor has kept the following comments:

  • // #define THIS 99
  • // Comment A
  • /* Comment B */
  • // Comment C

The #define directives HIGH and LOW have been converted into their defined values, and the comment alongside HIGH has been removed. The #define directive THIS is considered a comment because that line starts with //, and therefore has not been converted.

Non-ConfidentialPDF file icon PDF version100067_0609_00_en
Copyright © 2014–2017 Arm Limited (or its affiliates). All rights reserved.