Must POSIX 1003.1 include files be standalone?

Rainer Orth ro at thp.uni-koeln.de
Sat May 11 14:06:15 AEST 1991


Submitted-by: ro at thp.uni-koeln.de (Rainer Orth)

Recently while working on the command sources of Andy Tanenbaums Minix 1.6
(currently in beta and trying to become fully P1003.1 and .2 compatible),
there appeared the question whether code like

	#include <pwd.h>
	
	int main (void)
	{
	}

is required to work in a strictly conforming POSIX.1 implementation with
Standard C Bindings. 

The problem is as follows:

	<pwd.h> contains a prototype for struct passwd *getpwuid (uid_t)
	and doesn't include <sys/types.h> by itself. I'm not shure if the
	above program needs to #include <sys/types.h> itself or <pwd.h> is
	wrong. From P1003.1-1988 <sys/types.h> needs to be included only if
	the program uses getpwuid().

The same problem occurs in several other headers: e.g. <signal.h>, <grp.h>,
<unistd.h>, <sys/wait.h>.

Does P1003.1-1990 specify the correct behaviour?

	Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Institute of Theoretical Physics, University of Cologne

Internet: ro at thp.Uni-Koeln.DE

Volume-Number: Volume 23, Number 65



More information about the Comp.std.unix mailing list