Boost logo

Boost :

From: Christoph Ludwig (cludwig_at_[hidden])
Date: 2004-07-15 12:42:00


On Thu, Jul 15, 2004 at 10:02:22AM -0700, Robert Ramey wrote:
> Guillaume Melquiond wrote:
[...]
> >So it may be a good idea to completely remove the function "tmpnam" from
> >the Serialization library and use a saner replacement instead. This way,
> >the library tests would compile without any complaint from the linker on
> >Linux.
>
> I need this functionality to run the tests. What is the best way to go
> about it?

The (linux) man page tmpnam(3) recommends to use mkstemp(3)
instead. (It should be available on most Unix systems since it is
a POSIX function. I don't know about Windows.)

However, mkstemp(3) not only generates a unique filename but it also
opens the corresponding file and returns the file descriptor. You'd
have to close the file, possibly remove it, and then pass the filename
to the constructor of your stream which will create and open the file
again. That sounds like a hack to me and may not be portable.

But do you really need a new temporary filename in each test run?
I fail to see why it is a problem if each test uses a dedicated
filename. It does not make sense to run several instances of a
particular test in parallel, does it?

Regards

Christoph

-- 
http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html
LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk