FIX: thread-safe build fails
FIX: MSVC won't compile unless we stick to C89 or switch to C++ :(
Merge pull request #8 from narkq/windows-compat

Windows build fixes