ro@thp.uni-koeln.de (Rainer Orth) (05/11/91)
Submitted-by: ro@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@thp.Uni-Koeln.DE
Volume-Number: Volume 23, Number 65
decot@hpcupt1.cup.hp.com (Dave Decot) (05/16/91)
Submitted-by: decot@hpcupt1.cup.hp.com (Dave Decot) > 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. No. But it is allowed to work. Note that POSIX.1 permits any symbols ending in _t, including uid_t, to appear in any of its headers (i.e., those not imported from ANSI C). > 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(). To conform to POSIX.1-1988 or POSIX.1-1990, the program has to include <sys/types.h> first. > The same problem occurs in several other headers: e.g. <signal.h>, <grp.h>, > <unistd.h>, <sys/wait.h>. Same applies to them. > Does P1003.1-1990 specify the correct behaviour? It is clearer in this regard, although POSIX.1-1988 also required that the prerequisite #includes be there as well. POSIX.1-1991 will *require* that implementations provide stand-alone headers. In addition, a program will need to include *at most* one header in order to use a particular function (the one that contains the prototype for the function). Dave Decot Volume-Number: Volume 23, Number 73
arnold%audiofax.com@mathcs.emory.edu (Arnold Robbins) (05/17/91)
Submitted-by: arnold%audiofax.com@mathcs.emory.edu (Arnold Robbins) In article <1991May17.011208.6853@uunet.uu.net> decot@hpcupt1.cup.hp.com (Dave Decot) writes: >POSIX.1-1991 will *require* that implementations provide stand-alone >headers. In addition, a program will need to include *at most* one header >in order to use a particular function (the one that contains the prototype >for the function). Er, what is POSIX-1.1991? Didn't we just get through getting POSIX-1.1990? -- Arnold Robbins AudioFAX, Inc. | Threads are the 2000 Powers Ferry Road, Suite 200 / Marietta, GA. 30067 | lack of an idea. INTERNET: arnold@audiofax.com Phone: +1 404 618 4281 | -- Rob Pike UUCP: emory!audfax!arnold Fax-box: +1 404 618 4581 | [ Another year, another standard. -- mod ] Volume-Number: Volume 23, Number 74