[英]'yield' is not a member of 'std::this_thread'
I tried to yield current thread: 我试图产生当前线程:
std::this_thread::yield();
的std :: this_thread ::收率();
But unfortunately GCC knows better: 但不幸的是GCC知道的更好:
'yield' is not a member of 'std::this_thread'
'yield'不是'std :: this_thread'的成员
Have I forgotten about some hack similar to D_GLIBCXX_USE_NANOSLEEP, or what? 我忘了一些类似于D_GLIBCXX_USE_NANOSLEEP的黑客攻击,或者是什么?
Yes, this appears to be an issue similar to the one with _GLIBCXX_USE_NANOSLEEP
. 是的,这似乎是与
_GLIBCXX_USE_NANOSLEEP
类似的问题。 GCC has yield
conditionally compiled depending on the macro _GLIBCXX_USE_SCHED_YIELD
. GCC根据宏
_GLIBCXX_USE_SCHED_YIELD
有条件地编译yield
。 It should compile if you define that. 如果你定义它,它应该编译。
This will be fixed as of GCC 4.8. 这将在GCC 4.8中修复。
You shouldn't define _GLIBCXX_USE_NANOSLEEP
or _GLIBCXX_USE_SCHED_YIELD
in your code. 您不应在代码中定义
_GLIBCXX_USE_NANOSLEEP
或_GLIBCXX_USE_SCHED_YIELD
。 They are GCC/libstdc++-internal macros, so that's what should define it. 它们是GCC / libstdc ++ - 内部宏,所以应该定义它。 If they aren't defined, it's because GCC wasn't configured with the option to check for availability of the functions.
如果没有定义它们,那是因为GCC没有配置检查功能可用性的选项。 Since there are apparently no downsides to enabling that option for whatever system it is you're using, you could ask whoever provides your GCC to do so.
因为对于你正在使用的任何系统来说,启用该选项显然没有任何缺点,你可以问任何提供你的GCC的人这样做。 Until that's done, a safer hack than enabling the macro in your code is to modify the
c++config.h
file on your system to define the macros. 在此之前,比在代码中启用宏更安全的hack是修改系统上的
c++config.h
文件以定义宏。
You may need to use '--enable-libstdcxx-time' when configuring gcc to enable detection of sched_yield. 在配置gcc以启用sched_yield检测时,您可能需要使用'--enable-libstdcxx-time'。 For some reason, there is a single check for multiple features
出于某种原因,只需检查多个功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.