CL.EXE Input Files

A command-line token that does not begin with a hyphen, forward slash or @ sign (and, exceptionally, is not an argument for some earlier option) names an input file. CL recognises several types of input file. The type is ordinarily inferred from the (case-insensitive) extension in the name as given.

Extension Type
.c C source file
.cpp C++ source file
.cxx C++ source file
.def linker input file (via /def option)
.exp linker input file
.lib linker input file
.obj linker input file
.res linker input file

However, this inference of the type from the file extension is abandoned under the influence of the /TC, /TO and /TP options, which each set one type (C source file, object file and C++ source file, respectively) for all input files that are named in their own command-line tokens, whatever the file extensions.

An input file can also be named through the /Tc, /To or /Tp options, with the file type then being implied by the option (C source file, object file or C++ source file, respectively).

An input file whose type is not decided by the above rules is ordinarily treated as an object file, after a warning (D4024). However, if the compiler is limited to pre-processing because of a /E or /EP option (though not the otherwise closely related /P), unrecognised input files are instead treated as C source files, with no warning.

Compiler Modules

Each of the different types of input file has a different selection of compiler modules (including the linker) that can be involved with the file.

Input File Type Compiling (C1) Compiling (C1XX) Processing Generating Code (C2) Linking (LINK)
C source file yes no yes yes yes
C++ source file no yes yes yes yes
linker input file no no no no yes

Under the action of various compiler options (/B1_5, /BK, /c, /E, /EP, /P, /Zg, /Zs and /ZX), one or more modules can be disabled. If it turns out that the modules wanted for working with some input file are all disabled, the file is ignored after a warning (D4027).