I'm porting over some really old (and massive base of) code from CentOS 6 to Ubuntu 14.04. Note, I've installed the expected older version of gcc, fixed linker references, etc.
My build attempt is progressing, but I'm stuck on one thing. There's a C file that's trying to create a struct of type rusage
, but the Ubuntu environment is giving me the following error: error: storage size of 'rusage' isn't known
As far as I can tell, all my paths look correct. I've even looked in the time.h and resource.h system files on each system (CentOS where it works and Ubuntu where it does not work). There seem to be references to a wait.h file where rusage is actually defined, just the same.
What else could I possibly be missing in my Ubuntu environment?
Edit: Adding more MCVE-ish details...
My build is stopping with the following error:
vmodem.c:6747: error: storage size of 'rusage' isn't known
That line in the file is simply:
struct rusage rusage
The required includes are all in that file as well (<sys/time.h>
, <sys/wait.h>
, etc.)
Not sure what else I can provide in this case...
The man page for
getrusage
on both CentOS 6 and Ubuntu 14.04 says that one should include<sys/time.h>
and<sys/resource.h>
.You mentioned that you include
<sys/wait.h>
. It has a forward declarationstruct rusage;
so that the declarations ofwait3
andwait4
will be valid, but that forward declaration isn't sufficient to let you declare a struct of typerusage
.Things work on CentOS 6 because CentOS 6's
wait.h
contains a line#include <sys/resource.h>
, andresource.h
does fully declarestruct rusage
, but Ubuntu 14.04'swait.h
does not contain a#include <sys/resource.h>
line.