From: Eddie Diener (eddielee_at_[hidden])
Date: 2004-07-16 23:11:27
Robert Ramey wrote:
> Guillaume Melquiond wrote:
>> I see the serialization library uses "tmpnam" quite a lot. I don't
>> know what the status of this function is on other operating system.
>> But on GNU/Linux at least (and I suppose it is the same for any
>> POSIX system), it is considered to be bad practice . Such a bad
>> practice that the linker ld is especially programed to complain
>> whenever somebody uses this function. Moreover, I see that Borland
>> and Microsoft compilers "have
> brain->dead tmpnam functions"  so a replacement was needed.
>> 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
> about it?
The main danger of tmpnam is not that someone else may use the name, since a
new unique name is returned each time, but rather that one may not have the
rights to create a file in the current directory. Under Windows you could
2) _tempnam for compilers which support it ( both VC++ and C++ Builder do )
3) GetTempPath followed by GetTempFileName, both Windows APi functions
I don't see any mkstemp under Windows.
It would be nice if the filesystem library had a way of creating a temporary
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk