Hi,
I cannot compile the thread example listed on the document:
http://www.boost.org/libs/thread/doc/thread.html#Example
I'm using g++ 2.95.3 on a FreeBSD 4.x box. Here are the exact
environment and compile error messages:
% uname -a
FreeBSD XXX.foo.bar 4.5-PRERELEASE FreeBSD 4.5-PRERELEASE #0: Tue Jan 8 03:14:40 CST 2002 root@XXX.foo.bar:/usr/src/sys/compile/kernel.XXX i386
% g++ -v
Using builtin specs.
gcc version 2.95.3 20010315 (release) [FreeBSD]
% cat test_thread0.cpp
#include
#include
#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;
};
void run()
{
int secs = 5;
std::cout << "setting alarm for 5 seconds..." << std::endl;
boost::thread thrd(thread_alarm(secs));
std::cout << "main()" << std::endl;
thrd.join();
}
int main()
{
run();
}
% g++ -I/usr/local/include test_thread0.cpp
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)'
The boost library is installed through FreeBSD's ports collection which the boost version is 1.26.0.
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?
ps. The example seems lack of a xtime inclution. So I add the #include at the first line:
#include
--
Chien-Chou Hung / Jeff Hung / 洪健洲 (Big5)
National Chiao Tung University
Institute of Information Management
交通大學資訊管理所碩士生
http://www.jeffhung.idv.tw/
mailto:jeffhung.iim90g@nctu.edu.tw