2009/05/31

TRACE and CString of VC in UNICODE

Default TCHAR of VC2005 or later is UNICODE. CString template class also use UNICODE as CStringW by default. For example, TRACE(_T"%s"), _T("Foo"));

Bug on Various Arguments

TRACE and other printf-like function have varargs, which are not work implicit type conversion because these types are not known by the compiler. As conversion operator of CString works in other case, the fact that conversion is not work may be forgotten. This mismatch occurs undefined-behavior of C++. The below example is modified to the following; CString foo; TRACE(_T("%s"),static_cast(foo));

IO error on TRACE in Japanese with UNICODE

TRACE may fail to output Japanese by default. In this case, VC say "_CrtDbgReport: String too long or IO Error". Its solution is the following; #include
std::setlocale(LC_ALL, "Japanese");

No comments:

How to set parameters to debugging program on Visual Studio 2019 with CMake

Solution: MSDN Sometimes the "Debug and Launch Settings for CMake" bottun is disabled. In this case, change to the target view. ...