
void foo(string & str) { str = "foo"; } int main(int argc, char * argv[]) { string str1("Hello world"); string str2(str1); thread trd1(bind(&foo, str1)); thread trd2(bind(&foo, str2)); trd1.join(); trd2.join(); return 0; } The following is the compile log: Compiling... testThread.cpp d:\Programming\boost\boost\boost\thread\exceptions.hpp(29) : warning C4275: non dll-interface class 'std::logic_error' used as base for dll-interface class 'boost::lock_error' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\stdexcept(14) : see declaration of 'std::logic_error' d:\Programming\boost\boost\boost\thread\exceptions.hpp(28) : see declaration of 'boost::lock_error' d:\Programming\boost\boost\boost\thread\exceptions.hpp(35) : warning C4275: non dll-interface class 'std::runtime_error' used as base for dll-interface class 'boost::thread_resource_error' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\stdexcept(136) : see declaration of 'std::runtime_error' d:\Programming\boost\boost\boost\thread\exceptions.hpp(34) : see declaration of 'boost::thread_resource_error' d:\Programming\boost\boost\boost\thread\mutex.hpp(37) : warning C4275: non dll-interface class 'boost::noncopyable' used as base for dll-interface class 'boost::mutex' d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable' d:\Programming\boost\boost\boost\thread\mutex.hpp(36) : see declaration of 'boost::mutex' d:\Programming\boost\boost\boost\thread\mutex.hpp(75) : warning C4275: non dll-interface class 'boost::noncopyable' used as base for dll-interface class 'boost::try_mutex' d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable' d:\Programming\boost\boost\boost\thread\mutex.hpp(74) : see declaration of 'boost::try_mutex' d:\Programming\boost\boost\boost\thread\mutex.hpp(115) : warning C4275: non dll-interface class 'boost::noncopyable' used as base for dll-interface class 'boost::timed_mutex' d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable' d:\Programming\boost\boost\boost\thread\mutex.hpp(114) : see declaration of 'boost::timed_mutex' d:\Programming\boost\boost\boost\thread\thread.hpp(39) : warning C4275: non dll-interface class 'boost::noncopyable' used as base for dll-interface class 'boost::thread' d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable' d:\Programming\boost\boost\boost\thread\thread.hpp(38) : see declaration of 'boost::thread' d:\Programming\boost\boost\boost\thread\thread.hpp(68) : warning C4275: non dll-interface class 'boost::noncopyable' used as base for dll-interface class 'boost::thread_group' d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable' d:\Programming\boost\boost\boost\thread\thread.hpp(67) : see declaration of 'boost::thread_group' d:\Programming\boost\boost\boost\thread\thread.hpp(79) : warning C4251: 'boost::thread_group::m_threads' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'boost::thread_group' with [ _Ty=boost::thread * ] d:\Programming\boost\boost\boost\bind.hpp(186) : error C2664: 'void (std::string &)' : cannot convert parameter 1 from 'const std::string' to 'std::string &' Conversion loses qualifiers d:\Programming\boost\boost\boost\bind\bind_template.hpp(21) : see reference to function template instantiation 'R boost::_bi::list1<A1>::operator ()<boost::_bi::bind_t<R,F,L>::result_type,void(__cdecl *)(std::string &),boost::_bi::list0>(boost::_bi::type<T>,F,A &) const' being compiled with [ R=boost::_bi::bind_t<void,void (__cdecl *)(std::string &),boost::_bi::list1<boost::_bi::list_av_1<std::string>::B1>>::result_type, A1=boost::_bi::list_av_1<std::string>::B1, F=void (__cdecl *)(std::string &), L=boost::_bi::list1<boost::_bi::list_av_1<std::string>::B1>, T=boost::_bi::bind_t<void,void (__cdecl *)(std::string &),boost::_bi::list1<boost::_bi::list_av_1<std::string>::B1>>::result_type, A=boost::_bi::list0 ] d:\Programming\boost\boost\boost\bind\bind_template.hpp(19) : while compiling class-template member function 'boost::_bi::bind_t<R,F,L>::result_type boost::_bi::bind_t<R,F,L>::operator ()(void)' with [ R=void, F=void (__cdecl *)(std::string &), L=boost::_bi::list1<boost::_bi::list_av_1<std::string>::B1> ] d:\Programming\project\testBoost\testThread\testThread.cpp(36) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled with [ R=void, F=void (__cdecl *)(std::string &), L=boost::_bi::list1<boost::_bi::list_av_1<std::string>::B1> ] Build log was saved at "file://d:\Programming\project\testBoost\testThread\Debug\BuildLog.htm" testThread - 1 error(s), 8 warning(s) Any suggestions are appreciated.