tons of errors because boost::thread::thread() in thread/detail/thread.hpp is private
I am successfully using Boost.Thread on Windows without a hitch, but when porting my program to OSX I get the following compile error, followed by an enormous chain of errors that probably are a derivative of it: ./boost/thread/detail/thread.hpp:108: error: ‘boost::thread::thread(boost::thread&)’ is private When checking the class that it mentioned, it appears that it is in fact declared as private for some reason. Is there a reason I'm only receiving this error on OSX, and how can it be fixed?
It turns out that a relatively obscure mistake on my part caused the slew of
errors: I made the boost::thread object's name the exact same as the
function it was to launch. It turns out that on Windows, this was not a
problem, but on OSX it caused a bunch of unhelpful errors, including the one
I mentioned.
On Sat, Nov 7, 2009 at 7:36 PM, tiredashell
I am successfully using Boost.Thread on Windows without a hitch, but when porting my program to OSX I get the following compile error, followed by an enormous chain of errors that probably are a derivative of it:
./boost/thread/detail/thread.hpp:108: error: ‘boost::thread::thread(boost::thread&)’ is private
When checking the class that it mentioned, it appears that it is in fact declared as private for some reason. Is there a reason I'm only receiving this error on OSX, and how can it be fixed?
2009/11/8 tiredashell
I am successfully using Boost.Thread on Windows without a hitch, but when porting my program to OSX I get the following compile error, followed by an enormous chain of errors that probably are a derivative of it:
./boost/thread/detail/thread.hpp:108: error: ‘boost::thread::thread(boost::thread&)’ is private
When checking the class that it mentioned, it appears that it is in fact declared as private for some reason. Is there a reason I'm only receiving this error on OSX, and how can it be fixed?
Do you by any chance have code like this? void Foo() {} int main() { boost::thread t = Foo; } Standard conforming compiler must reject this code, because boost::thread is not copyable (even though all modern compilers know how to elide this copy). As far as I remember, MS compiler will compile this code happily. The solution is to change the last line to this: boost::thread t(Foo); Here's another case where you might see the same problem: void Foo() {} void Bar(const boost::thread&) {} int main() { Bar(boost::thread(Foo)); } Again, MS compiler compiles it, but it should not, because C++03 requires boost::thread to be copyable in this case. HTH, Roman Perepelitsa.
participants (2)
-
Roman Perepelitsa
-
tiredashell