[lldb-dev] Heads up: Please don't use mkstemp
Zachary Turner
zturner at google.com
Fri Oct 17 16:48:19 PDT 2014
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 :)
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20141017/671dae18/attachment.html>
More information about the lldb-dev
mailing list