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
#include
#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@MorganStanley.com</a>