我目前正在编写一个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