This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix get_temp_file_name() to compile for Windows.
ClosedPublic

Authored by STL_MSFT on Apr 28 2016, 5:16 PM.

Details

Summary

[libcxx] [test] Fix get_temp_file_name() to compile for Windows.

It was including <io.h> but attempting to use GetTempPath() and GetTempFileName(), which are provided by <windows.h>.

Instead of dragging in <windows.h> (which is large), we can use _mktemp_s() from <io.h>.

Fixes MSVC errors:
"error C2065: 'MAX_PATH': undeclared identifier"
"error C3861: 'GetTempPath': identifier not found"
"error C3861: 'GetTempFileName': identifier not found"

Diff Detail

Event Timeline

STL_MSFT updated this revision to Diff 55512.Apr 28 2016, 5:16 PM
STL_MSFT retitled this revision from to [libcxx] [test] Fix get_temp_file_name() to compile for Windows..
STL_MSFT updated this object.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
EricWF accepted this revision.Apr 28 2016, 5:56 PM
EricWF edited edge metadata.

LGTM but I don't know much about Windows or MinGW.

This revision is now accepted and ready to land.Apr 28 2016, 5:56 PM
EricWF closed this revision.Apr 28 2016, 5:57 PM

r267963.

Er, I don't think mingw provides _mktemp_s.

Er, I don't think mingw provides _mktemp_s.

I went back to the old method for MinGW in r267968 just to be safe. Thanks for the input.

[David Majnemer]

Er, I don't think mingw provides _mktemp_s.

Yeah, I don't know what needs to be done for MinGW. (I avoided using _mktemp for MSVC because I knew it would complain about "security".)

I am pretty sure that this code was already broken for MinGW - I grepped and found no inclusions of windows.h throughout the tests, and I believe that MinGW's io.h and other CRT headers don't declare the windows.h GetTempPath/etc. machinery that this was trying to use.

[Eric Fiselier]

I went back to the old method for MinGW in r267968 just to be safe. Thanks for the input.

I should have done that in the first place to be non-intrusive. Sorry for the minor headache.

STL