3

C compilers supports generating the preprocessor output file with .i extension.
As far as I know, this is true for Microsoft (Visual Studio), ARM, Keil and some GNU compilers.

They usually use the compiler switch -E or -P for that.
There's also the compiler switch -C to retain comments.

Is the creation of preprocessor files a standard in ANSI-C, or is this compiler specific?
Is the option -C also a standard?

EDIT:
To be more precise: This is about the support for creation of the .i file, not the compiler switch syntax or names.

2
  • 2
    There is no standard for compiler switches/options what-so-ever, nor any standard for the format of any form of outputs from the pre-processor, the compiler or the linker. The C standard does not even assume that you are developing your program on an OS with a file system present. A C compiler yielding an output in brightly-colored pine cones instead of files, would still be fully compliant to the C standard. Commented Jun 13, 2013 at 8:34
  • @Lundin: So preprocessor output is just a offered feature of compiler developers? I was afraid of that. Commented Jun 13, 2013 at 9:04

2 Answers 2

3

It is not standardized in the ISO C standard.

However most compilers seem to have -E for generating prepro output. This is reasonable as the prepro output is often very useful for debugging.

Here is a list of compilers I checked:

  • gcc
  • pcc
  • clang
  • ctc (TriCore)
  • Tasking C166
  • Wind River (DIAB)

All these compilers allow writing the prepro output to any file (with any extension). The .i is definitely not standard.

The option -C for retaining comments seems to be rather specific.

Sign up to request clarification or add additional context in comments.

Comments

2

The C programming language standard doesn't specify anything about how compilers are invoked.

It might be an "ad hoc" standard, but it's not something that is controlled in any official fashion "globally". There are local standards, such as POSIX that can specify things like these, but that would of course not cover compilers implemented for non-POSIX environments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.