1.3.8. Using -x Option to Control Input File Interpretation

The c29clang compiler interprets source files with a recognized file extension in a predictable manner. The recognized file extensions include:

  • .c - C source file

  • .C or .cpp - C++ source file

  • .o - object file to be forwarded on to the linker

The c29clang compiler also supports a -x option that permits you to dictate how an input file is to be interpreted by the compiler. This can be used to override default file extension interpretations or to instruct the compiler how to interpret a file extension that is not automatically recognized by the compiler.

-x <language>

Interpret subsequent input files on the command line as <language> type files.

The following <language> types are available to the -x option:

  • -x none - Reset compiler to default file extension interpretation.

  • -x c - Interpret subsequent input files as C source files.

  • -x c++ - Interpret subsequent input files as C++ source files.

Note

The -x<language> option is position-dependent. A given -x option on the c29clang command line is in effect until the end of the command line or until a subsequent -x option is encountered on the command line.

The following example uses input files with missing or non-standard file extensions. In this case, the -x options serve to inform c29clang how each input file is to be interpreted:

c29clang -mcpu=c29.c0 -c -x c file1 -x c++ file2.cxx