improve compatibility with mingw, patch by Alain Frisch