C++ compatibility

Only C++ errors are fixed, no functionality changed.

Code now compatible with Visual Studio 2008. I think it's a good chance to increase number of active developers.
sprintf is not safe. Maybe we can provide a drop in replacement for Visual Studio (http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010).