問題
在 BCB6.0 下使用如下指令編譯 boost 1.39.0 的 thread 庫:
bjam --toolset=borland-6.0 --with-thread stage debug threading=multi link=shared
結果出現如下錯誤:
[C++ Error] thread.hpp(344): E2247 'thread::thread(thread &)' is not accessible
提示 thread::thread(thread &) 受到保護,不可訪問。
解決辦法
修改源碼,將 thread::thread(thread &) 方法的訪問限制改為 public。
打開檔案 boost\boost_1_39_0\boost\thread\detail\thread.hpp,定位到第 108 行:
class BOOST_THREAD_DECL thread
{
private:
//thread(thread&);
thread& operator=(thread&);
將 thread(thread&); 方法註釋掉,並把該方法的聲明移到 public 處(約第 146 行):
public:
thread();
~thread();
thread(thread&);
備註:編譯開源專案時,不到萬不得已最好不要去修改源碼。