I'm getting this error when trying to compile this simple program. The psinfo struct is in procfs.h. It's erroring on the definition line. Why would it not know the size of psinfo?
#include <sys/procfs.h>
int main(int argc, char *argv[]) {
struct psinfo p;
}
$ /usr/sfw/bin/gcc little.c
little.c: In function `main':
little.c:4: error: storage size of 'p' isn't known
Including sys/procfs.h
was done by older code using the ioctl-based proc interface. Not to break these programs, the psinfo
structure is currently kept undefined by default.
As you want to use the new interface, the simpler way to overcome this issue is to use this include statement:
#include <procfs.h>
which is documented in /usr/include/sys/procfs.h
:
/*
* This definition is temporary. Structured proc is the preferred API,
* and the older ioctl-based interface will be removed in a future version
* of Solaris. Until then, by default, including <sys/procfs.h> will
* provide the older ioctl-based /proc definitions. To get the structured
* /proc definitions, either include <procfs.h> or define _STRUCTURED_PROC
* to be 1 before including <sys/procfs.h>.
*/
Of course, predefining _STRUCTURED_PROC
to 1
like documented too will also work as you experienced.