From: Darin Adler (darin_at_[hidden])
Date: 2001-10-15 17:28:07
on 10/15/01 1:57 PM, williamkempf_at_[hidden] at williamkempf_at_[hidden]
> And, while I'm at it, there's a set of gcc warnings given when
> compiling with native Win32 threads that I could use some help on as
> well. Here's the output:
> action ..\..\..\libs\thread\build\bin\libboost_thread\gcc\release\runt
> ../src\once.cpp: In function `void boost::call_once(void (*)(),
> once_flag &)':
> ../src\once.cpp:61: warning: unsigned int format, DWORD arg (arg 3)
> ../src\once.cpp:61: warning: unsigned int format, pointer arg (arg 4)
These are warning about values passed to a printf-family function that do
not match the format in the printf string.
The sprintf format string uses %X to print the result of
GetCurrentProcessId() and %X to print the result of &flag.
In the case of GetCurrentProcessId, the problem is that %X means an unsigned
integer, but DWORD is not the same as "unsigned int". The best fix is
probably to add a conversion to unsigned int -- I suggest doing it with
assignment to a local variable.
In the case of the pointer, you are trying to print the value of a pointer.
One way to do that is with the "%p" format string. But that's risky since I
don't know exactly how wide the string written by %p is, and it's important
not to overflow the fixed-size buffer you are passing in to sprintf. There
may be other ways of printing the pointer as a number that are more suitable
-- perhaps a reinterpret cast to unsigned.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk