控制输出信息的宏

#pragma once #include <stdio.h> #define WIDEN2(x) L ## x #define WIDEN(x) WIDEN2(x) #define __WFILE__ WIDEN(__FILE__) //#define SAVE_LOG_FILE #ifdef DEBUG #ifdef SAVE_LOG_FILE #define DbgPrint(...)/ {/ FILE* pFile = _wfopen(LOG_FILE, L"a");/ if (pFile != NULL)/ {/ fwprintf(pFile,_T("FILE:%s(Line %d) "),__WFILE__,__LINE__);/ fwprintf(pFile,##__VA_ARGS__);/ fflush(pFile);/ fclose(pFile);/ pFile = NULL;/ }/ } #else #define DbgPrint(...)/ {/ wprintf(_T("FILE:%s(Line %d) "),__WFILE__,__LINE__);/ wprintf(##__VA_ARGS__);/ } #endif #else #ifdef SAVE_LOG_FILE #define DbgPrint(...)/ {/ FILE* pFile = _wfopen(LOG_FILE, L"a");/ if (pFile != NULL)/ {/ fwprintf(pFile,_T("FILE:%s(Line %d) "),__WFILE__,__LINE__);/ fwprintf(pFile,##__VA_ARGS__);/ fflush(pFile);/ fclose(pFile);/ pFile = NULL;/ }/ } #else #if 1 // temporarily modified, we will set it as 1 when we finally release the product #define DbgPrint(...) ((void)0) #else #define DbgPrint(...)/ {/ wprintf(_T("FILE:%s(Line %d) "),__WFILE__,__LINE__);/ wprintf(##__VA_ARGS__);/ } #endif #endif #endif

你可能感兴趣的:(控制输出信息的宏)