/Tc、/Tp、/TC、/TP(指定源文件类型)/Tc, /Tp, /TC, /TP (Specify Source File Type)

/Tc 选项将其 filename 参数指定为 c 源文件,即使该文件没有 .c 扩展名也是如此。The /Tc option specifies that its filename argument is a C source file, even if it does not have a .c extension. /Tp 选项指定其 filename 参数为 c + + 源文件,即使该文件没有 .cpp 或扩展名 .cxx 也是如此。The /Tp option specifies that its filename argument is a C++ source file, even if it doesn't have a .cpp or .cxx extension. 选项和文件名之间的空格是可选的。A space between the option and the filename is optional. 每个选项指定一个文件;若要指定其他文件,请重复选项。Each option specifies one file; to specify additional files, repeat the option.

/Tc/tp/tc/tp 的全局变量。/TC and /TP are global variants of /Tc and /Tp. 它们指定编译器将命令行上命名的所有文件视为 C 源文件 (/tc) 或 c + + 源文件 (/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. 可以通过 /tc/tp 在单个文件上覆盖这些全局选项。These global options can be overridden on a single file by means of /Tc or /Tp.

语法Syntax

/Tc 文件名/Tc filename
/Tp 文件名/Tp filename
/TC/TC
/TP/TP

参数Arguments

filenamefilename
C 或 c + + 源文件。A C or C++ source file.

备注Remarks

默认情况下, CL 假定扩展名为 c 的文件是 c 源文件,文件扩展名为 .cpp,或扩展名为 .cxx。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.

指定 tctc 选项时,将忽略 /zc: wchar_t () wchar_t 的任何规范。When either the TC or Tc option is specified, any specification of the /Zc:wchar_t (wchar_t Is Native Type) option is ignored.

在 Visual Studio 开发环境中设置此编译器选项To set this compiler option in the Visual Studio development environment

  1. 打开项目的“属性页” 对话框。Open the project's Property Pages dialog box. 有关详细信息,请参阅在 Visual Studio 中设置 C++ 编译器和生成属性For details, see Set C++ compiler and build properties in Visual Studio.

  2. 选择 "配置属性" " > c/c + + > 高级" 属性页。Select the Configuration Properties > C/C++ > Advanced property page.

  3. 修改 编译为 属性。Modify the Compile As property. 选择 "确定" 或 " 应用 " 以应用所做的更改。Choose OK or Apply to apply your changes.

以编程方式设置此编译器选项To set this compiler option programmatically

示例Examples

此 CL 命令行指定 prg、prg 和均为 C 源文件。This CL command line specifies that MAIN.c, TEST.prg, and COLLATE.prg are all C source files. CL 不会识别 prg。CL will not recognize PRINT.prg.

CL MAIN。C/TcTEST.PRG/TcCOLLATE.PRG 打印。PRGCL MAIN.C /TcTEST.PRG /TcCOLLATE.PRG PRINT.PRG

此 CL 命令行指定 TEST2、.cxx、TEST3 和 TEST4 被编译为 c + + 文件,而 TEST5 将编译为 C 文件。This 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。是 TEST4。O/Tc TEST5。Z/TPCL TEST1.C TEST2.CXX TEST3.HUH TEST4.O /Tc TEST5.Z /TP

请参阅See also

MSVC 编译器选项MSVC Compiler Options
MSVC 编译器 Command-Line 语法MSVC Compiler Command-Line Syntax