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");

2009/05/11

C2977 on MPL's List

Boost.Statechart uses Boost.Mpl's list. The list is limited to size by default, which yields the error C2977.

if the macro BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS and BOOST_MPL_LIMIT_MAP_SIZE as upper-limit number are defined, the error is resolved.

2009/05/10

Deserialization of Polymorphic Pointers does not work...

Deserialization of polymorphic pointers does not work...

Firstly, it is strange that BOOST_CLASS_EXPORT does not work, and seems no effects. text_iarchive throws unregistered class exception.

I understand that register_type is not necessary if I use the BOOST_CLASS_EXPORT; However, the register_type is called explicitly, the exception is not thrown. But, in the case with register_type, deserialized pointer's type is differ from its original object.

Boost.Serialization registers the entries at only first time and does not change those? Old version from Subversion, which has not refactered these derived classes, seem to work. Umm...

Memo on Visual C++ Debugger

I look for the following in MSDN sometimes:

_crtBreakAlloc
It is the global variable to set bugging break at memory leak position by VC debugger.
If crt is DLL(msvcrtd), use "{,,msvcr71d.dll}_crtBreakAlloc" instead of this.
err
It is the global variable of VC for debugging, which always hold the result of GetLastError.
hr
It means the value with the hr on VC's watch windows as HRESULT type .
wm
It means the value with the wm on VC's watch windows as WM_MESSAGE type.

2009/05/07

Boost.Asio.ip.tcp.Socket

I have rewritten from ip::tcp::iostream of Boost.Asio to ip::tcp::socket.
Although I am debugging it, the problem on blocking seems to resolve.

2009/05/06

GURPS 4th Basic Sets in PDF

I bought the Basic sets, Campaigns & Character, of GURPS 4th edition via e32 site of Steve Jackson Games.

I have owned hard-covered books of the basic sets. The books can be read more faster than pdf on display; However, the pdf can be searched, which is also useful.

Furthermore, pdf downloaded is more inexpensive than physical books import in Japan.

Um, how many rule books of GURPS 4th Ed, I have owned....

  • Basic set: Campaigns
  • Basic set: Characters
  • High-tech
  • Ultra-tech
  • Bio-tech
  • Supers
  • Powers
  • Fantacy
  • Magic
  • Thaumatology
  • Martial Arts
  • Spaceships

Boost 1.39

I have updated my development environment from Boost 1.37 to 1.39 in the other day.

It is mostly no problems. But, the headers of Boost.spirit is deprecated. Thus, I must check these shortly...

Boost.asio.ip.tcp.iostream may be half-duplex ?

I understood that ip::tcp::iostream of Boost.Asio can be realize for multi threading interactive server using multiple io_servives; However, it may not be true. In fact, I wrote the following, but ip::tcp::iostream::write is blocking during the stream is reading.

  • Main thread (cui thread) creates accepting thread
  • The accepting thread creates thread pool for io_service using boost::thread_group.
  • The accepting thread creates each communication agent on a thread when a new connection is accepted.
  • The agent thread is receiving to client's requests.
    Such behavior of client's request and its response is fine as I expect.
  • However, the server sends requests to clients in some cases. Then, the sending is blocking.

I will change from ip::tcp::iostream to asynchronous sockets of Boost.Asio...
Um, ASIO stads for Asynchronous I/O, which means answer ?

2009/05/05

Boost.Serialization with multi thread ... I/O?

text_oarchive constructor has not been completed while receiving of text_iarchive. Are the text_iarchive and text_oarchive sequential?

Official sample of Boost.Asio with Serialization uses stringstream as buffer...
Firstly, text_oarchive binds with ostringstream, and the result of ostringstream::str() is written to ip::tcp::iostream.
Text_iarchive and istringstream, too.

The following code has also not returned from iarchive's construction;

boost::asio::ip::tcp::iostream ios;
boost::archive::text_oarchive(ios);
boost::archive::text_iarchive(ios); // <- It never returns.

What am I wrong ? ... Usage of Boost.Asio ?

Memo on Boost Serialization & Asio

register_type() is required on building a polymorphic pointer from oarchive. In my situation, BOOST_CLASS_EXPORT and BOOST_CLASS_EXPORT_GUID are no effects. Why is unknown..

And, some typical bugs occur;

  • such polymorphic pointer requires virtual destructor.
  • Because the operator << of iostream deals string, zero value is not written.
These are easy mistake.

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. ...