Thursday, December 09, 2021

[Solved] error: ‘getrusage’ was not declared in this scope


Error:

vb_perf.cpp: In function ‘int main(int, const char**)’:
vb_perf.cpp:63:23: error: variable ‘main(int, const char**)::rusage rusage’ has initializer but incomplete type
   63 |         struct rusage rusage = { };
      |                       ^~~~~~
vb_perf.cpp:64:19: error: ‘RUSAGE_SELF’ was not declared in this scope
   64 |         getrusage(RUSAGE_SELF, &rusage);
      |                   ^~~~~~~~~~~
vb_perf.cpp:64:9: error: ‘getrusage’ was not declared in this scope; did you mean ‘rusage’?
   64 |         getrusage(RUSAGE_SELF, &rusage);
      |         ^~~~~~~~~
      |         rusage


Solution:

Include this header to your source code:

#include <sys/resource.h>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.