Boost logo

Boost Users :

From: brian_todoroff_at_[hidden]
Date: 2001-11-20 05:16:39


I've been trying for a few hours now to get the threads lib examples
to compile. I built the libraries with jam and all but python built
correctly.
When I create a new Win32 console application and copy the code ( See
end of message from the thread class example and attempt to compile I
get:

===================Start Error
--------------------Configuration: threadtest - Win32 Debug-----------
---------
Compiling...
threadtest.cpp
c:\projects\boost\threadtest\threadtest.cpp(27) : error C2228: left
of '.join' must have class/struct/union type
Error executing cl.exe.
Creating browse info file...

threadtest.exe - 1 error(s), 0 warning(s)
===================End Error

Can't figure out what I'm doing wrong. Thanks for any help.

Brian Todoroff

========================Start Code (to end)
#include <boost/thread/xtime.hpp>
#include <boost/thread/thread.hpp>
#include <iostream>

struct thread_alarm
{
   thread_alarm(int secs) : m_secs(secs) { }
   void operator()()
   {
       boost::xtime xt;
       boost::xtime_get(&xt, boost::TIME_UTC);
       xt.sec += m_secs;

       boost::thread::sleep(xt);

       std::cout << "alarm sounded..." << std::endl;
   }

   int m_secs;
};

int main(int argc, char* argv[])
{
   int secs = 5;
   std::cout << "setting alarm for 5 seconds..." << std::endl;
   boost::thread thrd(thread_alarm(secs));
   thrd.join(); // Line 27 - Error here
   return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net