gpt4 book ai didi

c++ - C++ 中的 sysconf() 错误

转载 作者:搜寻专家 更新时间:2023-10-31 01:33:51 26 4
gpt4 key购买 nike

我正在编译一个程序,它给出了以下错误。 gcc的版本是(GCC) 4.8.5 20150623 (Red Hat 4.8.5-4。

Utils.cpp: In static member function ‘static double Utils::process_mem_usage()’:
Utils.cpp:33:30: error: ‘_SC_PAGE_SIZE’ was not declared in this scope
long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // if x86-64 is configured to use 2MB pages
^
Utils.cpp:33:43: error: ‘sysconf’ was not declared in this scope
long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // if x86-64 is configured to use 2MB pages

最佳答案

包括<unistd.h> , 其中_SC_PAGE_SIZE被定义并且 sysconf() 已声明。

参见 POSIX 规范:http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

关于c++ - C++ 中的 sysconf() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40615175/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com