我目前正在編寫一個firebreath C++ NPAPI插件,並且試圖從插件內部調用boost :: thread。我構建它的平臺是Ubuntu Linux 13.04。下面是類的聲明和相關的成員函數實現的骨架:在boost :: thread構造函數中調用boost :: bind()的編譯器錯誤
class EmulatorLaunchPluginAPI : public FB::JSAPIAuto
{
public:
EmulatorLaunchPluginAPI(const EmulatorLaunchPluginPtr& plugin,
const FB::BrowserHostPtr& host):m_plugin(plugin), m_host(host)
{
registerMethod("launch_emulator",
make_method(this, &EmulatorLaunchPluginAPI::launch_emulator));
registerMethod("launch_emulator_thread",
make_method(this, &EmulatorLaunchPluginAPI::launch_emulator_thread));
}
virtual ~EmulatorLaunchPluginAPI() {};
EmulatorLaunchPluginPtr getPlugin()
{
EmulatorLaunchPluginPtr plugin(m_plugin.lock());
if (!plugin) {
throw FB::script_error("The plugin is invalid");
}
return plugin;
}
bool launch_emulator(const std::string& ,const FB::JSObjectPtr&)
{
emt(boost::bind(//boost::type<void>(),
&EmulatorLaunchPluginAPI::launch_emulator_thread,
this,
cmd,
callback));
return true;
}
void launch_emulator_thread(const std::string& , const FB::JSObjectPtr&)
{
//thread body logic here
int result = 0;
result = invoke_command(cmd);
//callback to the browser
callback->InvokeAsync("", FB::variant_list_of(shared_from_this())(result));
}
private:
int invoke_command(const std::string&)
{
int res = system("/usr/bin/firefox");
return res;
}
EmulatorLaunchPluginWeakPtr m_plugin;
FB::BrowserHostPtr m_host;
boost::thread emt;
};
I am getting the following compile error for the code fragmented highlighted above:
[54%]大廈CXX對象的項目/ EmulatorLaunchPlugin/CMakeFiles/EmulatorLaunchPlugin.dir/EmulatorLaunchPluginAPI.cpp.o /家庭/阿賈伊/下載/firebreath-FireBreath-c335f5b/projects/EmulatorLaunchPlugin/EmulatorLaunchPluginAPI.cpp:在成員函數 '布爾EmulatorLaunchPluginAPI :: launch_emulator(常量字符串&,常量JSObjectPtr &)': /家庭/阿賈伊/下載/ firebreath-fireBreath-c335f5b /項目/EmulatorLaunchPlugin/EmulatorLaunchPluginAPI.cpp:94:30:error:不匹配調用'(boost :: thread)(boost :: _ bi :: bind_t &,co nst boost :: shared_ptr &>,boost :: _ bi :: list3,boost :: _ bi :: value>,boost :: _ bi :: value>>>)' make [2]:* [projects/EmulatorLaunchPlugin/CMakeFiles/EmulatorLaunchPlugin.dir/EmulatorLaunchPluginAPI.cpp.o]錯誤1個 化妝[1]: [項目/ EmulatorLaunchPlugin/CMakeFiles/EmulatorLaunchPlugin.dir /所有]錯誤2 化妝:* * [全部]錯誤2
我是Boost Libraries的新手,我也嘗試瞭解boost :: bind是如何工作的,但是我無法解決這個錯誤。有人能幫我理解編譯器的行爲嗎?
問候, 阿賈伊
請,使用C++註釋以表明錯誤的網站,cuz'*** emt(...'看起來像'emt'的三重引用。和下一個'; *** return'我的內部解析器得到ICE%) – zaufi
也有錯誤的w/錯誤信息。它看起來像部分複製粘貼...調用'(boost :: thread)(boost :: _ bi :: bind_t&,const boost :: shared_ptr&>' - 我沒有看到相應的開放角度支架 – zaufi
@zaufi:感謝評論...我有將編譯器輸出封裝在引起文本誤報的塊引用中......請在文章的修訂版中找到原始錯誤...關注,Ajay – user2688183