Boost logo

Boost Users :

From: Peisheng Wang (peisheng.wang_at_[hidden])
Date: 2008-05-07 23:09:20


 g++ boo_t.cpp 
-L../resource/boost_1_35_0/bin.v2/libs/thread/build/gcc-4.1.2/release/threading-multi/libboost_thread-gcc41-mt-1_35.so.1.35.0
-Lpthread
boo_t.cpp: In function ‘void increment_count()’:
boo_t.cpp:14: error: reference to ‘mutex’ is ambiguous
boo_t.cpp:10: error: candidates are: boost::mutex mutex
/usr/include/boost/thread/mutex.hpp:35:
error:                 class boost::mutex

code:
#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <iostream>

using namespace std;
using namespace boost;

int count = 0;
boost::mutex mutex;

void increment_count()
{
   boost::mutex::scoped_lock lock(mutex);
   std::cout << "count = " << ++count << std::endl;
}

int main(int argc, char* argv[])
{
   boost::thread_group threads;
   for (int i = 0; i < 10; ++i)
      threads.create_thread(&increment_count);
   threads.join_all();
"boo_t.cpp" 24L,
480C                                        
1,1           Top

c

--
Peisheng Wang
Software Engineer
iZENEsoft (Shanghai) Co., Ltd
Room 601
Marine Tower, No. 1 Pudong
Ave.
Tel:86-21-68860698-114
Fax:86-21-68860699
Company Website:<a
target="_blank"
href="http://www.izenesoft.com/">www.izenesoft.com</a>
<a
href="../../../../index.php?menuaction=felamimail.uicompose.compose&send_to=Wmhlbi5ZdUBNb3JnYW5TdGFubGV5LmNvbQ==">Zhen.Yu_at_[hidden]</a>



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