-qsourcetype

Description

Instructs the compiler to treat all recognized source files as if they are the source type specified by this option, regardless of actual source filename suffix.

Syntax

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

where:

Source Type Suffix Behavior
default - The compiler assumes that the programming language of a source file will be implied by its filename suffix.
c
  • .c
  • .i

    (for preprocessed files)

The compiler compiles all source files following this option as if they are C language source files.
c++
  • .C, .cc, .cpp, .cxx
  • .cp, .c++
The compiler compiles all source files following this option as if they are C++ language source files.
assembler
  • .s
The compiler compiles all source files following this option as if they are Assembler language source files.
assembler-with-cpp
  • .S
The compiler compiles all source files following this option as if they are Assembler language source files that needs preprocessing.

Notes

The -qsourcetype option should not be used together with the -+ option.

The -qsourcetype option instructs the compiler to not rely on the filename suffix, and to instead assume a source type as specified by the option.

Ordinarily, the compiler uses the filename 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, a .C suffix normally implies C++ source code, and the compiler will treat them as follows:

hello.c
The file is compiled as a C file.
hello.C
The file is compiled as a C++ file.

This applies whether the file system is case-sensitive or not. However, in a case-insensitive file system, the above two compilations refer to the same physical file. That is, the compiler still recognizes the case difference of the filename argument on the command line and determines the source type accordingly, but will ignore the case when retrieving the file from the file system.

Examples

To treat the source file hello.C as being a C language source file, enter:

xlc -qsourcetype=c hello.C

Related information