Windows: Fixed build (and a handful of warnings)

Switched Windows-specific source files to .cpp, corrected system header
problems, fixed casting issues.