[comp.os.minix] pwd.h

jcook@uhasun.hartford.edu (John Cook) (05/08/91)

Greetings. Recently, I obtained a copy of the VN program that was posted
to this newsgroup. It certainly looks good, & complete. However [isnt there
always], when I tried to compile [make] it, the compiler stated that two
lines in /usr/include/pwd.h, which is #included in envir_set.c, are 
"old-fashioned", and terminated compilation. Also, a make error of 236 or
something was  generated. Apparently, those lines are:

uid_t pw_uid
gid_t pw_gid

or close. Any ideas, anyone??

 john

evans@syd.dit.CSIRO.AU (Bruce.Evans) (05/09/91)

In article <610@ultrix.uhasun.hartford.edu> jcook@uhasun.hartford.edu (John Cook) writes:
>Greetings. Recently, I obtained a copy of the VN program that was posted
>...
>"old-fashioned", and terminated compilation. Also, a make error of 236 or
>something was  generated. Apparently, those lines are:
>
>uid_t pw_uid
>gid_t pw_gid

It was not clear if the POSIX standard requires the following program to
work:

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

<sys/types.h> has to be included before <pwd.h> to be sure of it working.
vn is an old program and its author did not allow for such brain damage.

It's not difficult to implement <pwd.h> to be independent of <sys/types.h>
but this was not done. As a work-around, I changed <pwd.h> to include
<sys/types.h>. This pollutes the name space but is better than failure to
compile.

The same problem also affects these files:

fcntl.h grp.h signal.h

which traditionally don't need <sys/types.h>. (signal.h only needs it
when _POSIX_SOURCE is defined.)

The problem affects these files to a lesser extent because there is
less tradition:

dirent.h unistd.h utime.h utmp.h
-- 
Bruce Evans		evans@syd.dit.csiro.au

tgcpwd@rw8.urc.tue.nl (Wim van Dorst) (05/10/91)

In article <610@ultrix.uhasun.hartford.edu> jcook@uhasun.hartford.edu (John Cook) writes:
>Greetings. Recently, I obtained a copy of the VN program that was posted
>to this newsgroup. It certainly looks good, & complete. However [isnt there
>always], when I tried to compile [make] it, the compiler stated that two
>lines in /usr/include/pwd.h, which is #included in envir_set.c, are 
>"old-fashioned", and terminated compilation. Also, a make error of 236 or
>something was  generated. Apparently, those lines are:
>
>uid_t pw_uid
>gid_t pw_gid

Obvious: precede the line #include<pwd.h> with a line
	#include <sys/types.h>
Then uid_t and gid_t will be typedef'ed, and be recognized by the compiler.

-b-b-
-- 
---------------------------------------------------------------------
Blue Baron = Wim van Dorst, Voice (+31) 074-443937, (+31) 02152-42319
(-:       baron@wiesje.hobby.nl           tgcpwd@urc.tue.nl       :-)
---------------------------------------------------------------------

ast@cs.vu.nl (Andy Tanenbaum) (05/10/91)

In article <1991May9.003612.24952@syd.dit.CSIRO.AU> evans@syd.dit.CSIRO.AU (Bruce.Evans) writes:
@It was not clear if the POSIX standard requires the following program to
@work:
@
@----
@#include <pwd.h>
@main() {}
@----

It is also not clear what the ANSI C standard says.  having <sys/types.h>
included automagically has implications for name space pollution.

Andy Tanenbaum (ast@cs.vu.nl)

P.S. When I use @ instead of > in quoted text, it is to prevent the stupid
news program from rejecting my message because I quoted too much.