#define에서 문장의 중간에 나타나는 #의 의미는?
글쓴이: haewoo / 작성시간: 월, 2004/07/26 - 10:44오전
#define TRACE(l,s) { if (CheckTraceLev(l)) { TrcPrintf_##l s ; } }
#if ( defined (__GNUG__) && defined (_SYSTYPE_SVR4) ) || defined (__UNIX__)
#include <syslog.h>
#else
#define LOG_EMERG 0 // An extreme emergency
#define LOG_ALERT 1 // A condition that should be corrected immedialtely
#define LOG_CRIT 2 // A critical condition like a hardware error
#define LOG_ERR 3 // An error that require attention but is not critical
#define LOG_WARNING 4 // A warning that an error condition may exist
#define LOG_NOTICE 5 // A condition tha in not an error, but may need
// attention
#define LOG_INFO 6 // An informational message (e.g., a message issued
// when a server starts execution)
#define LOG_DEBUG 9 // A message used by programmer for debugging
#endif
int EXPORT TrcPrintf_LOG_EMERG (const char *fmt, ...);
int EXPORT TrcPrintf_LOG_ALERT (const char *fmt, ...);
int EXPORT TrcPrintf_LOG_CRIT (const char *fmt, ...);
int EXPORT TrcPrintf_LOG_ERR (const char *fmt, ...);
int EXPORT TrcPrintf_LOG_WARNING (const char *fmt, ...);
int EXPORT TrcPrintf_LOG_NOTICE (const char *fmt, ...);
int EXPORT TrcPrintf_LOG_INFO (const char *fmt, ...);
int EXPORT TrcPrintf_LOG_DEBUG (const char *fmt, ...);
int EXPORT TrcPrintf_MAX_TRC_LEV (const char *fmt, ...);
int EXPORT TrcPrintf_MIN_TRC_LEV (const char *fmt, ...);
int EXPORT TrcPrintfDeb (int x, const char *fmt, ...);
int EXPORT TrcPrintfTst (int x, const char *fmt, ...);
int EXPORT TrcPrintfRel (int x, const char *fmt, ...);
int EXPORT CheckTraceLev (const int level)
{
return (CurTraceLev = level) <= TraceLevel;
}
// Logger 호출부분
TRACE(LOG_INFO,("File: %s version %s compiled on %s %s",file,id,date,time));
위의 소스에서 #define TRACE(l,s) { if (CheckTraceLev(l)) { TrcPrintf_##l s ; } }의 "#"이 뭘 의미하는 건가요???
C++은 그리 많이 사용해 보지 않아서.. 의미파악이 힘드네요..
Forums:


~~~##X 는 ~~~X로 치환하라는 의미입니다. 페이스트 토큰
~~~##X 는
~~~X로 치환하라는 의미입니다. 페이스트 토큰인가?
명칭이 있는데.... 아무튼 뒤의 X토큰을 붙이는 역할을 합니다.
위의 예에서는
TRACE(l,s) 로 되어있으므로
중간에
TRACE(ixevexi, kldp)라면
{ if (CheckTraceLev(l)) { TrcPrintf_ixevexi kldp ; } }
가 될 것입니다.
C++, 그리고 C++....
죽어도 C++
감사...
감사...
댓글 달기