#include <windows.h>
#include <strsafe.h>
#include <comdef.h>
#define _DEBUG_BUF_SIZE_ 1048
static char _buf_[_DEBUG_BUF_SIZE_];
class trace_impl
{
public:
trace_impl(const char* file,size_t line):file_(file),line_(line)
{
}
inline void operator() (const wchar_t* format,...) const
{
char msg[_DEBUG_BUF_SIZE_];
wchar_t buf[_DEBUG_BUF_SIZE_*2];
va_list args;
va_start(args, format);
StringCbVPrintfW(buf,_DEBUG_BUF_SIZE_, format, args);
//OutputDebugStringW(buf);
va_end(args);
StringCbPrintfA(msg,_DEBUG_BUF_SIZE_," in %s(%d)",file_,line_);
//StringCchPrintfW
_bstr_t t;
t = buf;
t += msg;
OutputDebugStringW((const wchar_t*)t);
}
private:
const char* file_;
size_t line_;
};
#ifdef _DEBUG
#define LogView trace_impl(__FILE__,__LINE__)
#else
#define LogView //
#endif
int main(int argc, char* argv[])
{
LogView(L"%s",L"safedebug");
return 0;
}
vc6 调试输出行号加强版
最新推荐文章于 2020-07-06 11:02:56 发布