Fix a first batch of mingw32 (gcc 6) compilation issues
Those fixes are mostly trial and error from someone with little experience with Windows compilers (especially getting things to work for both MinGW32 and MSVC), so there is likely room for improvement.