Boost logo

Boost Users :

From: Justin Crites (pyxl_at_[hidden])
Date: 2001-11-21 23:35:57


This is a problem of VC interpreting the statement as a function
declaration. Modify to the following:

thread_alarm alarm(secs);
boost::thread thrd( alarm );

...and it should compile.

Make sure you link with the multithreaded DLL libraries.

Justin

-----Original Message-----
From: brian_todoroff_at_[hidden] [mailto:brian_todoroff_at_[hidden]]
Sent: Tuesday, November 20, 2001 2:17 AM
To: Boost-Users_at_[hidden]
Subject: [Boost-Users] Threads on MSVC 6.0

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;
}

Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
 

Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/


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