5.7.2.7 X: Specify Source Language Option

The -x language option specifies the language for the sources files that follow on the command line.

The compiler usually uses the extension of an input file to determine the file’s content. This option allows you to have the language of a file explicitly stated. The option remains in force until another language is specified with a -x option, or the -x none option, which turns off the language specification entirely for subsequent files. The allowable languages are tabulated below.

Table 5-7. Source file Language
LanguageFile language
assemblerAssembly source
assembler-with-cppAssembly with C preprocessor directives
cC source
c++C++ source
cpp-outputPreprocessed C source
c-headerC header file
noneBased entirely on the file’s extension

The -x assembler-with-cpp language option ensures assembly source files are preprocessed before they are assembled, thus allowing the use of preprocessor directives, such as #include, and C-style comments with assembly code. By default, assembly files not using a .S extension are not preprocessed.

You can create precompiled header files with this option, for example:
xc32-gcc -mprocessor=32MZ2048ECH100 -x c-header init.h
will create the precompiled header called init.h.gch.