Print null correctly
[folly.git] / folly / String.cpp
index 66649caaaa5bdcb9f0b95de415bf4a59c81ff6d0..5042cec97a53a1a05daf50c4be5f4fa3425107f4 100644 (file)
@@ -330,7 +330,7 @@ fbstring errnoStr(int err) {
 
   // https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/strerror_r.3.html
   // http://www.kernel.org/doc/man-pages/online/pages/man3/strerror.3.html
-#if defined(_WIN32) && defined(__MINGW32__)
+#if defined(_WIN32) && (defined(__MINGW32__) || defined(_MSC_VER))
   // mingw64 has no strerror_r, but Windows has strerror_s, which C11 added
   // as well. So maybe we should use this across all platforms (together
   // with strerrorlen_s). Note strerror_r and _s have swapped args.
@@ -342,9 +342,8 @@ fbstring errnoStr(int err) {
   } else {
     result.assign(buf);
   }
-#elif defined(__APPLE__) || defined(__FreeBSD__) ||\
-    defined(__CYGWIN__) || defined(__ANDROID__) ||\
-    ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE)
+#elif defined(FOLLY_HAVE_XSI_STRERROR_R) || \
+  defined(__APPLE__) || defined(__ANDROID__)
   // Using XSI-compatible strerror_r
   int r = strerror_r(err, buf, sizeof(buf));