Date: 2001-10-16 02:44:29
--- In boost_at_y..., Darin Adler <darin_at_b...> wrote:
> on 10/15/01 1:57 PM, williamkempf_at_h... at williamkempf_at_h...
> > ../src\once.cpp:61: warning: unsigned int format, DWORD arg (arg
> > ../src\once.cpp:61: warning: unsigned int format, pointer arg
> These are warning about values passed to a printf-family function
> not match the format in the printf string.
std::ostringstream has been designed to avoid these problems.
HANDLE mutex = CreateMutex(NULL, FALSE, name);
you could include <sstream> and use
name << "2AC1A572DB6944B0A65C38C4140AF2F4"
<< std::hex << GetCurrentProcessId()
HANDLE mutex = CreateMutex(NULL, FALSE, name.str().c_str());
This is type safe and avoids potential problems with buffer overflows;
in particular, it should also work on future windows version
were the return type of GetCurrentProcessId() might change
OTOH you have an additional dependecy on <sstream>
and a (negligible?) performance penalty
for the dynamic memory allocation in std::ostringstream.
For <sstream> and GCC 2.95,
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk