[Issue 24315] dmd/cpreprocess.d:87: warning: the use of `tmpnam' is dangerous, better use `mkstemp'
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jan 6 06:52:59 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24315
--- Comment #6 from kdevel <kdevel at vogtner.de> ---
(In reply to Walter Bright from comment #5)
> It returns a file descriptor for an already opened file.
The descriptor is unused and can be safely closed (or the FILE* ptr fclosed
after using fdopen). Using mkstemp is how to create a named temporary file lege
artis in GNU/Linux [5].
The actual filename is in the writable template-buffer given as parameter to
mkstemp. The preprocessor will put its output into that file.
I was under the impression that not the POSIX but the Windows version could
pose
problems here?
[5] sec 2.2.2. (p. 7) of Ulrich Drepper: Defensive Programming for Red Hat
Enterprise Linux (and What To Do If Something Goes Wrong)
http://people.redhat.com/drepper/defprogramming.pdf
--
More information about the Digitalmars-d-bugs
mailing list