提升线程中出现错误"expression cannot be used as a function"?
Error "expression cannot be used as a function" in boost thread?
我在OpenSUSE和Boost 1.55上使用QT-Creator。生成所需的所有二进制文件。
该程序很简单,可以测试Boost线程的功能。只声明一个线程。
当构建程序时,我有以下错误
/home/esys/Documents/Boost/headers/boost/thread/detail/thread.hpp:117: error: expression cannot be used as a function
f();
^
在thread.hpp中是这样的:
void run()
{
f();// line 117
}
private:
F f;
};
我对此感到很困惑,因为问题似乎是标题本身的代码而不是构建设置的东西!
如何解决这个问题?当然,我可以改变到另一个Boost版本,但我有点好奇这个错误。这是Boost库,伙计们!
我可以重现你的问题,你的线程声明:
boost::thread *p = new boost::thread("thread1");
无效:构造函数需要一个可调用对象(如functor),而不是string
。您应该查看boost文档以获取更多信息。
(错误消息实际上是相当明确的:它告诉你你的表达式_字符串"thread1" _是不可调用的)
注意:
考虑std::thread
作为boost::thread
的替代品,如果你的编译器支持c++ 11。
相关文章:
- SFINAE:"enable_if cannot be used to disable this declaration"
- 如何理解"abstract-declarator containing an ellipsis shall only be used in a parameter-declaration"
- 解决方法:'can not be used when making a shared object; recompile with -fPIC'使用Cmake。使用普通的 g++ 工作
- "expression cannot be used as a function"回报声明
- 为什么这句话"The expression can be used only as the left-hand operand of a member function call"在 [expr.re
- 析构函数提供删除资源的"may be used uninitialized"
- " 'yc' can not be used as a function"错误C++
- Clang - 删除某些文件的"conversion function converting <A> to base class <B> will never be used"
- Qt信号/插槽中的'expression cannot be used as a function'
- 来自 MSDN 的 InternetGetConnectedState 和"it should not be used from a service"声明
- 一系列"cannot be used as a function"的 Dev++ 总和
- "unspecialized class template can't be used as a template argument"是什么意思?
- 禁用优化时没有"may be used uninitialized"
- 链接错误:"relocation R_X86_64_32 ... can not be used when making a shared object; recompile with -fPIC"
- 在窗口错误中使用QProcess启动进程:"Timers can only be used with threads started with QThread"
- 提升线程中出现错误"expression cannot be used as a function"?
- 如何解决"class must be used when declaring a friend"错误?
- "The input/output library <stdio.h> shall not be used."
- 为什么" 'static' may not be used when defining (as opposed to declaring) a static data member"?
- Can Dropbox Djinni be used with C++98