Boost logo

Boost Users :

From: bill_kempf (williamkempf_at_[hidden])
Date: 2002-05-16 13:55:17


--- In Boost-Users_at_y..., "imi123_1999" <imi123_1999_at_y...> wrote:
> I am a newbie so please help me a little. I am using Visual C++ 6.0
> in order to compile a program given as an example of threads.

Where did you get the example from? What version of Boost are you
using?

> I am
> also copying the program below. But the problem is that the program
> is giving errors of unresolved externals. Please tell me how to
> change the settings of VC++ options. Here is the program:
>
> #include <boost/thread/thread.hpp>
> #include <iostream>
>
> int count = 0;
> boost::mutex mutex;
>
> void increment_count()
> {
> boost::mutex::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();
> }
>
>
> The errors i am getting are:
>
> C:\Windows\Desktop\threadImI\imi.cpp(9) : error C2039: 'lock' : is
> not a member of 'mutex'
> c:\program files\microsoft visual studio\vc98
> \include\boost\thread\mutex.hpp(35) : see declaration of 'mutex'
> C:\Windows\Desktop\threadImI\imi.cpp(9) : error C2065: 'lock' :
> undeclared identifier
> C:\Windows\Desktop\threadImI\imi.cpp(9) : error C2146: syntax
error :
> missing ';' before identifier 'lock'
> C:\Windows\Desktop\threadImI\imi.cpp(19) : warning C4508: 'main' :
> function should return a value; 'void' return type assumed
> Error executing cl.exe.
> Creating browse info file...
>
> threadImI.exe - 3 error(s), 3 warning(s)

The name "lock" was changed to "scoped_lock" quite some time ago. I
don't know where you got the example from, but if it's in the current
documentation it needs fixing.

Bill Kempf


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