1.3.8. Using -x Option to Control Input File Interpretation

1.3.8.1. Interpretation of Source Files

The tiarmclang compiler will interpret 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

  • .s - GNU-syntax Arm assembly source file

  • .S - GNU-syntax Arm assembly source file to be preprocessed by the compiler

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

1.3.8.1.1. Controlling Source File Interpretation with the -x Option

The tiarmclang compiler also supports a -x option that permits a user 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

  • -x assembler - interpret subsequent files as GNU-syntax Arm assembly source files

  • -x assembler-with-cpp - interpret subsequent files as GNU-syntax Arm assembly source files that will be preprocessed by the compiler

  • -x ti-asm - interpret subsequent source files as legacy TI-syntax assembly source files causing the compiler to invoke the legacy TI-syntax Arm assembler to process them. For more information about handling legacy TI-syntax Arm assembly source files, please see Invoking the TI-Syntax ARM Assembler from tiarmclang.

Note

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

1.3.8.1.2. Examples

  • In the following example, the -x ti-asm option is used to force a_ti_asm.asm to be interpreted as a TI-syntax assembly source file. The subsequent -x none is used to instruct tiarmclang to use its default input file interpretations for the remaining input files on the command-line:

tiarmclang -mcpu=cortex-m0 -c -x ti-asm a_ti_asm.asm -x none a_gnu_asm.s a_c.c
  • The following example uses input files with missing or non-standard file extensions. In this case, the -x options serve to inform tiarmclang how each input file is to be interpreted:

tiarmclang -mcpu=cortex-m0 -c -x c file1 -x assembler file2.xyz