'CPP'에 해당되는 글 1건

  1. 2009.06.03 [VisualStudio] C -> CPP, CPP -> C 로 컴파일 하기


[VisualStudio] C -> CPP, CPP -> C 로 컴파일 하기

Development/C / C++ 2009. 6. 3. 17:36
Visual Studio 6.0에서 C 확장자로 된 파일을 CPP로 컴파일 하거나 CPP 확장자로 된 파일을 C 파일로 컴파일 하기 위해서는
아래와 같은 옵션을 사용하면 가능하다.

/TC : CPP 확장자를 가진 파일을 C 확장자로 컴파일
/TP : C확장자를 가진 파일을 CPP 확장자로 컴파일


아래는 MSDN의 내용
/Tc, /Tp, /TC, /TP   (Specify Source File Type)

Syntax

/Tcfilename
/Tpfilename
/TC
/TP

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.

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 FOO1.C, FOO2.CXX, FOO3.HUH, and FOO4.O are compiled as C++ files, and FOO5.Z is compiled as a C file.

CL FOO1.C FOO2.CXX FOO3.HUH FOO4.O /Tc FOO5.Z /TP

*Visual Studio 2005에서는 Compile As 라는 옵션으로 설정이 가능하다.
: