/Tc 选项指定 filename 为 C 源文件,即使它没有 .c 扩展名。/Tp 选项指定 filename 为 C++ 源文件,即使它没有 .cpp 或 .cxx 扩展名。选项和 filename 之间的空格可选。每个选项指定一个文件;若要指定其他文件,请重复此选项。/TC 和 /TP 是 /Tc 和 /Tp 的“全局”变形。它们指定编译器将在命令行上指定的所有文件视为 C 源文件 (/TC) 或 C++ 源文件 (/TP),而不考虑它们在命令行上相对于选项的位置。这些全局选项可以在单个文件上通过 /Tc 或 /Tp 重写。默认情况下,CL 假定扩展名为 .c 的文件是 C 源文件,扩展名为 .cpp 或 .cxx 的文件是 C++ 源文件。示例
下列 CL 命令行指定 MAIN.c、TEST.prg 和 COLLATE.prg 都是 C 源文件。CL 将不识别 PRINT.prg。
CL MAIN.C /TcTEST.PRG /TcCOLLATE.PRG PRINT.PRG
下列 CL 命令行指定 TEST1.c、TEST2.cxx、TEST3.huh 和 TEST4.o 作为 C++ 文件编译,TEST5.z 作为 C 文件编译。
CL TEST1.C TEST2.CXX TEST3.HUH TEST4.O /Tc TEST5.Z /TP

解决方案 »

  1.   

    /Tp 选项指定 filename 为 C++ 源文件,即使它没有 .cpp 或 .cxx 扩展名
      

  2.   

    /TP 是/Tp 的全局变量。它指定编译器将在命令行上命名的所有文件视为  C++ 源文件,而不考虑它们在命令行上相对于选项的位置。
      

  3.   

    麻烦各位大师仔细看看我的问题。最好能帮我指出我们的命令行里说明那些C文件会被当作C++文件处理。另外treat as c++,是不是意味着对应的文件的编译结果中的函数、变量会被按照C++的方式修饰。多谢多谢!
      

  4.   

    经过我的测试发现,因为我的工程的命令行中没有列出任何文件,所以,C文件会被C编译器编译,C++文件会被C++编译器编译。
    这只是根据实验结果得到的结论,哪位大师有不同意见,还望指正。
      

  5.   

    /Tc, /Tp, /TC, /TP (Specify Source File Type)See Also
    Compiler Options | Setting Compiler Options
    /Tcfilename
    /Tpfilename
    /TC
    /TP
    where: filename 
    A C or C++ source file. 
    Res
    The /Tc option specifies that filename is a C source file, even if it doesn't have a .c extension. The /Tp option specifies that filename is a C++ source file, even if it doesn't have a .cpp or .cxx extension. A space between the option and filename is optional. Each option specifies one file; to specify additional files, repeat the option./TC and /TP are "global" variants of /Tc and /Tp. They specify to the compiler to treat all files named on the command line as C source files (/TC) or C++ source files (/TP), without regard to location on the command line in relation to the option. These global options can be overridden on a single file via /Tc or /Tp. By default, CL assumes that files with the .c extension are C source files and files with the .cpp or the .cxx extension are C++ source files. To set this compiler option in the Visual Studio development environment Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties. 
    Click the C/C++ folder. 
    Click the Advanced property page. 
    Modify the Compile As property. 
    To set this compiler option programmaticallySee CompileAs Property.Examples
    The following CL command line specifies that MAIN.c, TEST.prg, and COLLATE.prg are all C source files. CL will not recognize PRINT.prg.CL MAIN.C /TcTEST.PRG /TcCOLLATE.PRG PRINT.PRG
    The following CL command line specifies that TEST1.c, TEST2.cxx, TEST3.huh, and TEST4.o are compiled as C++ files, and TEST5.z is compiled as a C file. CL TEST1.C TEST2.CXX TEST3.HUH TEST4.O /Tc TEST5.Z /TP
      

  6.   

    又做了一个测试,貌似TP,TC会影响所有源文件,不管是否列在command line中,个人猜测cl应该和gnu的makefile类似,根据某些隐含规则project中的所有源文件都应该算是在command line中,只是没有显式的写出来而已.