'C'에 해당되는 글 3건

  1. 2009.06.03 [VisualStudio] C -> CPP, CPP -> C 로 컴파일 하기
  2. 2008.03.25 Name mangling in C++
  3. 2007.04.24 The Function Pointer Tutorials


[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 라는 옵션으로 설정이 가능하다.
:

Name mangling in C++

Development/C / C++ 2008. 3. 25. 15:59
C++은 C언어를 지원한다. 그래서 예전의 C소스를 가져다가 사용할 수 있다.

C 언어는 symbol에서 함수의 이름만으로 찾을 수 있다. 이 것은 C언어가 같은 함수 이름을
사용하는 것을 허용하지 않기 때문인데, C++에서는 다형성으로 인해서 같은 이름을 사용할 수 있다. 그래서 함수이름만으로 찾는 것이 불가능하다.

이런 것을 위해서 내부적으로 함수 이름을 변경해주는데 이것이 name mangling 이다.

다음과 같이 된다.

int foo(void)  {return 1;}
int foo(int ) {return 1;}
void goo(void) { int i=foo(), j=f(0); }



int _foo_i (void)  {return 1;}
int _foo_v (int ) {return 1;}
void _goo_i (void) { int i=_foo_i(), j=_foo_v(0); }




참조 : http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B




:

The Function Pointer Tutorials

Development/C / C++ 2007. 4. 24. 15:46

The Function Pointer Tutorials

  Extensive Index
  2.  The Syntax of C and C++ Function Pointers
  3.  How to Implement Callbacks in C and C++ ?
  4.  Functors to encapsulate C and C++ Function Pointers
  5.  Topic Specific Links




-------------------------------------------------------------------------------
Function Pointer에 대한 Tutorial이 있는 곳.
Lars의 홈페이지
출처 : http://www.newty.de/fpt/index.html

: