Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MasashiWada/55aba070057b0d18d4e690dc03189118 to your computer and use it in GitHub Desktop.

Select an option

Save MasashiWada/55aba070057b0d18d4e690dc03189118 to your computer and use it in GitHub Desktop.
void LogInternalW(const TCHAR* format, const char*file, const int line, ...)
{
TCHAR nfmt[1010];
{
TCHAR c[1010];
WCHAR wfile[204];
size_t len = 0;
int l;
va_list argList;
memset(c, 0, sizeof(c));
va_start(argList, line);
l = _vstprintf_s(c, 1010, format, argList);
va_end(argList);
c[l] = 0;
mbstowcs_s(&len, wfile, 200, file, _TRUNCATE);
wfile[len] = 0;
l = _stprintf_s(nfmt, 1000, _T("%s (%s:%d)\n"), c, wfile, line);
nfmt[l] = 0;
}
OutputDebugString(nfmt);
}
#define Log(fmt,...) LogInternalW(fmt,__FILE__,__LINE__,__VA_ARGS__)
@MasashiWada
Copy link
Author

VC++で使いたいので無くさないように書き足しました。
ワイド文字ビルド環境前提です。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment