Fix compile errors under mingw-w64.

To be included in PR #7626, as discussed in IRC.