본문 바로가기
Programming/C & C++

define 관련 재미있는 사용법

by leanu 2008. 5. 6.
#define 에서 정의한 2개의 인자를 붙어서 하나의 스트링으로 쓸수 있다.

가령 func(x,y) 를 주었을때 x와 y의 내용을 붙어서

변수명으로 선언하고 싶은경우 아래의 방법을 참고하면 된다.

#define concat(x,y) int x##y;

이런경우 아래에서

concat(Time, Check) 라고 사용하면

TimeCheck 를 int 형 변수로 이용할 수 있다.

실로 재미있는 일이다.




http://msdn.microsoft.com/en-us/library/09dwwt6y(VS.80).aspx


http://www.keil.com/support/man/docs/c166/c166_pp_tokenpastingop.htm

댓글