0

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...

csr19us
  • 105
  • 9
  • Instead of this bunch of hardly related information, present some code and how do you get the error. – Eugene Sh. Dec 29 '15 at 19:08
  • @EugeneSh. ~I'd be open to sharing the pertinent code, but the codebase is massive and very complex, to post any meaningful portion of it would be information overload. If the issue is in my codebase, then I'll try to handle that myself. What I'm looking for are any known issues with rusage in Ubuntu... particularly in relation to RHEL. Or anyone who's ran into something similar. Etc. – csr19us Dec 29 '15 at 19:11
  • 2
    Either there is a typo, or sys/resource.h (sys/time.h should work as well) isn't include? Show the code. – sheikh_anton Dec 29 '15 at 19:11
  • @csr19us, just create a MVCE - https://stackoverflow.com/help/mcve You will need it to test anyway. – sheikh_anton Dec 29 '15 at 19:13
  • The problem is in the code. It happens when you try to declare or allocate or just `sizeof` variable of an incomplete type (`rusage` in your case). – Eugene Sh. Dec 29 '15 at 19:13
  • @coredump, my file includes sys/time.h ~ I'll verify whether adding sys/resource.h makes a difference in Ubuntu (if it's not already included, that is) ~thanks for the idea – csr19us Dec 29 '15 at 19:27
  • Please post the pre-processor output for the file compile which fails (on some pastebin). You can get the output by replacing the `-c` option in the compile command with `-E`. – Ziffusion Dec 29 '15 at 20:10

2 Answers2

2

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 declaration struct rusage; so that the declarations of wait3 and wait4 will be valid, but that forward declaration isn't sufficient to let you declare a struct of type rusage.

Things work on CentOS 6 because CentOS 6's wait.h contains a line #include <sys/resource.h>, and resource.h does fully declare struct rusage, but Ubuntu 14.04's wait.h does not contain a #include <sys/resource.h> line.

Mark Plotnick
  • 9,598
  • 1
  • 24
  • 40
0

Thanks to coredump and Eugene Sh. for the tips... adding #include <sys/resource.h> was the trick.

It must have been something that worked in CentOS but not Ubuntu. At any rate, simply including the resource header file shouldn't hurt anything.

csr19us
  • 105
  • 9