Question

I'm new in using boost and have a problem. I need shared_mutex function in my project. So I've done

#include "boost/thread/shared_mutex.hpp"

And compiled my project. My MSVC 2005 with "treat warnings as errors" stops compilation because of a warning:

c:\\...\microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion from 'int' to 'unsigned short', possible loss of data

I have no idea, why shared_mutex needs microseconds function (I've read than boost libraries have rather big dependences list), but i can't compile my project. I've googled a bit, found same problem, but no decision.

UPDATE: I'm compiling boost now, but i want to put all sources to my open-source project, including boost.thread.shared_mutex.

Was it helpful?

Solution

I'll bet they're doing a += on an unsigned short. The result of the addition gets cast to an int implicitly, then needs to be downcast back to an unsigned short for the assignment.

OTHER TIPS

Various Boost libraries generate all kinds of warnings on Visual Studio builds at level 4. We just disable them.

For example, one of our precompiled header files has:

#pragma warning(push, 0)
#include <boost/asio.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/noncopyable.hpp>
#include <boost/thread.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/system/error_code.hpp>
#include <boost/xpressive/xpressive.hpp>
#pragma warning(pop)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top