Boost logo

Boost Users :

From: Darin Adler (darin_at_[hidden])
Date: 2002-02-04 03:33:44


On 2/4/02 12:02 AM, jeffhung_at_[hidden] wrote:

> I cannot compile the thread example listed on the document:
> http://www.boost.org/libs/thread/doc/thread.html#Example
>
> [...]
>
> boost::thread thrd(thread_alarm(secs));
>
> [...]
>
> test_thread0.cpp: In function `void run()':
> test_thread0.cpp:28: request for member `join' in `thrd', which is of
> non-aggregate type `boost::thread ()(thread_alarm)'
>
> I've tried to figure out where the problem is and failed to find the
> definition of class thread. Do I miss something? Or, is it just a freebsd
> porting problem?

This is a bug in the example that has been fixed for the next upcoming Boost
release. The web site will be updated soon.

The problem line above is can be interpreted as a declaration of a function
named thrd with a parameter of type thread_alarm named secs, rather than a
declaration of an object named thrd. And the C++ rule is that if it can be a
function declaration, then it is. The fix is to replace the line with these
two lines:

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

Hope that helps.

    -- Darin


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