boost::thread and boost::bind
I am attempting to do this in vs.net 2003: int f(HANDLE, HANDLE, HANDLE); int main(int argc, char* argv[]) { HANDLE x; HANDLE y; HANDLE z; boost::thread* p = new boost::thread(boost::bind(f, x, y, z); p->join(); delete p; } As a contrived example it works. In my project it does not, spewing out 5 errors: 1) c:\src\include\boost\bind.hpp(62) : error C2825: 'F::result_type': cannot form a qualified name c:\src\include\boost\bind\bind_template.hpp(16) : see reference to class template instantiation 'boost::_bi::result_traits<R,F>' being compiled with [ R=boost::_bi::unspecified, F=int (__cdecl *)(HANDLE,HANDLE) ] c:\src\ansa-1.0\src\main\main.cpp(369) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled with [ R=boost::_bi::unspecified, F=int (__cdecl *)(HANDLE,HANDLE), L=boost::_bi::list3<boost::_bi::list_av_3<fd_xpt,fd_xpt,fd_xpt>:: B1,boost::_bi::list_av_3<fd_xpt,fd_xpt,fd_xpt>::B2,boost::_bi:: list_av_3<fd_xpt,fd_xpt,fd_xpt>::B3> ] 2) c:\src\include\boost\bind.hpp(62) : error C2039: 'result_type' : is not a member of 'operator``global namespace''' 3) c:\src\include\boost\bind.hpp(62) : error C2146: syntax error : missing ';' before identifier 'type' 4) c:\src\include\boost\bind.hpp(62) : error C2955: 'boost::_bi::type' : use of class template requires template argument list c:\src\include\boost\bind.hpp(94) : see declaration of 'boost::_bi::type' 5) c:\src\include\boost\bind.hpp(62) : fatal error C1903: unable to recover from previous error(s); stopping compilation note: fd_xpt is declared as "typedef HANDLE fd_xpt;", and c:\src\ansa-1.0\src\main\main.cpp(369) is similar to "boost::thread* p = new boost::thread(boost::bind(f, x, y, z);" in the example. It appears that the compiler thinks my first argument is a "int (__cdecl *)(HANDLE,HANDLE)" when it is most certainly a "int (__cdecl *)(HANDLE,HANDLE,HANDLE)". It used to take two arguments, but I've since added a third (it was at this very point that these errors crashed the party). I am sure that there is no declaration that specifies only two arguments: I've had two other developers verify this. I have cleaned my project multiple times, even by hand, as well as getting a clean source tree from cvs, and yet I still get these errors. Any suggestions on how to silence these errors are greatly appreciated. --mpeltzer goochrules@hotmail.com
On Apr 6, 2004, at 1:47 PM, GoochRules! wrote:
I am attempting to do this in vs.net 2003:
int f(HANDLE, HANDLE, HANDLE);
int main(int argc, char* argv[]) { HANDLE x; HANDLE y; HANDLE z;
boost::thread* p = new boost::thread(boost::bind(f, x, y, z);
It wants a void () function. You've given it an int () one. I'm not sure if there's a really slick way to discard that return value. Anyone?
On Tuesday 06 April 2004 03:12 pm, Scott Lamb wrote:
On Apr 6, 2004, at 1:47 PM, GoochRules! wrote:
I am attempting to do this in vs.net 2003:
int f(HANDLE, HANDLE, HANDLE);
int main(int argc, char* argv[]) { HANDLE x; HANDLE y; HANDLE z;
boost::thread* p = new boost::thread(boost::bind(f, x, y, z);
It wants a void () function. You've given it an int () one. I'm not sure if there's a really slick way to discard that return value. Anyone?
The slick way to discard the return value is to do nothing :) A function<void(...)> discards the return value already. Doug
nevermind. I had a copy of the an old header file with the 2-parameter declaration that was being included prior to the new file.
participants (3)
-
Douglas Gregor
-
GoochRules!
-
Scott Lamb