我正在编译一个程序,它给了我以下错误。 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
答案 0 :(得分:3)
包括<unistd.h>
,其中_SC_PAGE_SIZE
已定义且宣布sysconf()
。
请参阅POSIX规范:http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html