Add support for MSVC

This patch set adds support for building with MSVC and nmake by making the source code compilable as C++ and compiling as C++ under MSVC. It also fixes a couple of cross-platform issues and introduces a `config.h` header that contains the results of several feature tests.