-qsourcetype

Category

Input control

Pragma equivalent

None.

Purpose

Instructs the compiler to treat all recognized source files as a specified source type, regardless of the actual file name suffix.

Ordinarily, the compiler uses the file name suffix of source files specified on the command line to determine the type of the source file. For example, a .c suffix normally implies C source code. The -qsourcetype option instructs the compiler to not rely on the file name suffix, and to instead assume a source type as specified by the option.

Syntax

Read syntax diagramSkip visual syntax diagram
                       .-default------------.   
>>- -q--sourcetype--=--+-assembler----------+------------------><
                       +-assembler-with-cpp-+   
                       '-c------------------'   

Defaults

-qsourcetype=default

Parameters

assembler
All source files following the option are compiled as if they are assembler language source files.
assembler-with-cpp
All source files following the option are compiled as if they are assembler language source files that need preprocessing.
c
All source files following the option are compiled as if they are C language source files.
default
The programming language of a source file is implied by its file name suffix.

Usage

If you do not use this option, files must have a suffix of .c to be compiled as C files.

This option applies whether the file system is case-sensitive or not. That is, even in a case-insensitive file system, where file.c and file.C refer to the same physical file, the compiler still recognizes the case difference of the file name argument on the command line and determines the source type accordingly.

Note that the option only affects files that are specified on the command line following the option, but not those that precede the option. Therefore, in the following example:
xlc goodbye.C -qsourcetype=c hello.C

hello.C is compiled as a C source file, but goodbye.C is compiled as a C++ file, assuming a C++ compiler is available.

Predefined macros

None.

Examples

To treat the source file hello.C as being a C language source file, enter:
xlc -qsourcetype=c hello.C