作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用这段代码来处理旧的 g++ 编译器。我从 this 得到这个回答。
unsigned thread::hardware_concurrency()
{
#if defined(PTW32_VERSION) || defined(__hpux)
return pthread_num_processors_np();
#elif defined(__APPLE__) || defined(__FreeBSD__)
int count;
size_t size=sizeof(count);
return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count;
#elif defined(BOOST_HAS_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN)
int const count=sysconf(_SC_NPROCESSORS_ONLN);
return (count>0)?count:0;
#elif defined(_GNU_SOURCE)
return get_nprocs();
#else
return 0;
#endif
}
这里是错误:
Hardware_con.h:31:25: error: ‘get_nprocs’ was not declared in this scope
return get_nprocs();
^
那么问题是我应该包含哪些头文件?
最佳答案
我们应该包含相应的头文件
#include <sys/sysinfo.h>
关于c++ - 错误 : ‘get_nprocs’ was not declared in this scope,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27981038/
考虑以下示例(来自 get_nprocs 手册页): #include #include #include int main(int argc, char *argv[]) { prin
我正在使用 get_nproc() 和 get_nprocs_conf() 获取机器中存在的在线数量和所有处理器核心的数量。 如何检查这些函数是否有错误。有具体的错误值吗?他们甚至会通知错误吗?不确定
我正在使用这段代码来处理旧的 g++ 编译器。我从 this 得到这个回答。 unsigned thread::hardware_concurrency() { #if defined(PTW32_V
我是一名优秀的程序员,十分优秀!