C++ mutex in namespace std does not name a type

前端 未结 11 907
日久生厌
日久生厌 2020-11-28 13:22

I\'m writing a simple C++ program to demonstrate the use of locks. I am using codeblocks and gnu gcc compiler.

 #inclu         


        
11条回答
  •  無奈伤痛
    2020-11-28 13:55

    Many classes of the standard thread library can be replaced with the boost ones. A very easy workaround is to change the entire standard mutex file with a couple of lines.

    #include 
    
    namespace std
    {
       using boost::mutex;
       using boost::recursive_mutex;
       using boost::lock_guard;
       using boost::condition_variable;
       using boost::unique_lock;
       using boost::thread;
    }
    

    And do not forget to link against boost thread library.

提交回复
热议问题