Various compilation fixes for windows

Fixed some compilation problems in MSVC.
And bugfix of improper format string in `--version` causing segfault