C++ implementation of xMsg