그중 제일 잘 쓰는건 __FILE__ (현재 파일 이름), __FUNCTION__ (현재 함수 이름), __LINE__ (현재 실행 라인)
정도.
이하 msdn 을 긁어왔다.
http://msdn.microsoft.com/ko-kr/library/b0084kay(v=VS.90)
Names the predefined ANSI C and Microsoft C++ implementation macros.
The compiler recognizes predefined ANSI C macros and the Microsoft C++ implementation provides several more. These macros take no arguments and cannot be redefined. Some of the predefined macros listed below are defined with multiple values. See the following tables for more information.
Macro |
Description |
---|---|
__DATE__ |
The compilation date of the current source file. The date is a string literal of the form Mmm dd yyyy. The month name Mmm is the same as for dates generated by the library function asctime declared in TIME.H. |
__FILE__ |
The name of the current source file. __FILE__ expands to a string surrounded by double quotation marks. To ensure that the full path to the file is displayed, use /FC (Full Path of Source Code File in Diagnostics). You can create your own wide string version of __FILE__ as follows: #include <stdio.h> #define WIDEN2(x) L ## x #define WIDEN(x) WIDEN2(x) #define __WFILE__ WIDEN(__FILE__) wchar_t *pwsz = __WFILE__; int main() {} |
__LINE__ |
The line number in the current source file. The line number is a decimal integer constant. It can be altered with a #line directive. |
__STDC__ |
Indicates full conformance with the ANSI C standard. Defined as the integer constant 1 only if the /Za compiler option is given and you are not compiling C++ code; otherwise is undefined. |
__TIME__ |
The most recent compilation time of the current source file. The time is a string literal of the form hh:mm:ss. |
__TIMESTAMP__ |
The date and time of the last modification of the current source file, expressed as a string literal in the form Ddd Mmm Date hh:mm:ss yyyy, where Ddd is the abbreviated day of the week and Date is an integer from 1 to 31. |
'C/C++언어' 카테고리의 다른 글
프로그램 시간 측정 (0) | 2012.03.21 |
---|---|
버츄얼과 오버라이드 차이 Virtual? Override? (0) | 2012.03.06 |
[C/C++] Debug Printf (0) | 2012.01.03 |
어셈블리 코드도 #if같은 메크로 분기시켜서 소스 관리하기. (0) | 2011.05.27 |
함수포인터를 이용한 콜백함수란? (0) | 2011.04.24 |