Heads up: Please don't use mkstemp

I’m mentioning this because previously I went through and fixed a bunch of uses of mkstemp. mkstemp doesn’t exist on Windows, and it’s not easy to implement it, so any generic code that relies on it won’t compile on Windows.

LLVM support libraries provide a similar function. It uses a different syntax for specifying the template than most people are familiar with, but it’s the only real cross-platform solution we have for achieving mkstemp-like functionality. It’s llvm::sys::fs::createUniqueFile().

In the future if you need mkstemp-like functionality, please consider using this function instead.

Also, just a friendly reminder that Windows paths don’t look like /foo/bar. If you find yourself hardcoding a path like this, it’s probably going to be broken on Windows. At some point I’ll figure it out and fix it, but if people get in the habit of not hardcoding paths it will make my life easier :slight_smile:

It’s not the slashes that matter so much as making assumptions about the filesystem layout (e.g. /usr, /bin, /tmp), or the fact that windows paths start with a drive letter. LLVM has a pretty nice filesystem abstraction library, and there are some additional improvements in lldb in Host/FileSystem.h.

Thanks!