-x (-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, and a .C suffix normally implies C++ source code. The -x 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
        .-none---------------.   
>>- -x--+-assembler----------+---------------------------------><
        +-assembler-with-cpp-+   
        +-c------------------+   
        '-c++----------------'   

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

Defaults

-x none or -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.
c++
All source files following the option are compiled as if they are C++ language source files. This suboption is equivalent to the -+ option.
default (-qsourcetype only)
The programming language of a source file is implied by its file name suffix.
none (-x only)
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, and .C (uppercase C), .cc, .cp, .cpp, .cxx, or .c++ to be compiled as C++ files.

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 -x c hello.C

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

Predefined macros

None.

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us