fix bug in errno mis-handling with MSVC