### Compiling Programs with Multiple Source Files

To compile programs that use more than one source file, specify all the filenames on the command line. For example, to compile a program with three source files (mainprog.c, subs1.c, and subs2.c), type:

       icc mainprog.c subs1.c subs2.c

The source file containing the main module can be anywhere in the list. The executable output file will have the same name as the first source file but with the extension .exe. In the example above, the executable file will be mainprog.exe.

You can compile a combination of C and C++ files. There are two ways to specify the file type.

- The file extension determines whether the file is compiled as a C file (.c or any other unrecognized extension) or as a C++ file (.cpp or .cxx). For example:

        icc  cprog.c cppprog.cpp cxxprog.cxx othprog.oth

- Use the /Tc, /Tp, and /Td options to specify whether a file is a C or C++ file, regardless of its extension. The /Tc and /Tp options apply only to the filename immediately following the option, and specify that the file is a C file (/Tc) or a C++ file (/Tp). For example, given the following command line:

        icc  /Tc cprog.cpp cppprog.cpp /Tp cxxprog.c

cprog.cpp is compiled as a C file, and cppprog.cpp and cxxprog.c are compiled as C++ files.

Summary of Compiler Options