[libcxx] r267963 - Fix get_temp_file_name() to compile on Windows. Patch from STL at microsoft.com

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 28 17:51:24 PDT 2016


Author: ericwf
Date: Thu Apr 28 19:51:24 2016
New Revision: 267963

URL: http://llvm.org/viewvc/llvm-project?rev=267963&view=rev
Log:
Fix get_temp_file_name() to compile on Windows. Patch from STL at microsoft.com

Modified:
    libcxx/trunk/test/support/platform_support.h

Modified: libcxx/trunk/test/support/platform_support.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/platform_support.h?rev=267963&r1=267962&r2=267963&view=diff
==============================================================================
--- libcxx/trunk/test/support/platform_support.h (original)
+++ libcxx/trunk/test/support/platform_support.h Thu Apr 28 19:51:24 2016
@@ -53,7 +53,7 @@
 #include <stdlib.h>
 #include <string>
 #if defined(_WIN32) || defined(__MINGW32__)
-#include <io.h> // _mktemp
+#include <io.h> // _mktemp_s
 #else
 #include <unistd.h> // close
 #endif
@@ -71,11 +71,13 @@ std::string
 get_temp_file_name()
 {
 #if defined(_WIN32) || defined(__MINGW32__)
-    char Path[MAX_PATH+1];
-    char FN[MAX_PATH+1];
-    do { } while (0 == GetTempPath(MAX_PATH+1, Path));
-    do { } while (0 == GetTempFileName(Path, "libcxx", 0, FN));
-    return FN;
+    char Name[] = "libcxx.XXXXXX";
+
+    if (_mktemp_s(Name, sizeof(Name)) != 0) {
+        abort();
+    }
+
+    return Name;
 #else
     std::string Name;
     int FD = -1;




More information about the cfe-commits mailing list