Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Jul 1996 18:11:17 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        current@freebsd.org, nnd@itfs.nsk.su
Subject:   Re: Current <dirent.h>, <sys/types.h> and POSIX (?)
Message-ID:  <199607240811.SAA16182@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>I was told (in qmail-beta mailing list) that by POSIX
>it is not necessary to include <sys/types.h> to use
><dirent.h>.

>Could someone POSIXly-impaired (:-) confirm that ?

No, POSIX.1 section 4.1.2.1 requires <sys/types.h> to be included
before <dirent.h>, even though the interfaces defined in <dirent.h>
don't depend explictly on any of the types declared in <sys/types.h>
(most POSIX interfaces do depend on these types so the requirement
for <sys/types.h> is obvious).

The old BSD <dirent.h> happened not to depend on any of the types in
<sys/types.h>.  This changed in BSD4.4Lite2.

>BTW, in NetBSD-current(?) <dirent.h> contains
>#include <sys/types.h> just before #include <sys/dirent.h>

I think NetBSD attempts to conform to X/OPEN and X/OPEN does require
it.  FreeBSD's <dirent.h> doesn't conform to POSIX anyway.  Even if
_POSIX_SOURCE is defined, it #defines many application identifiers:

	DTTOIF, DT_BLK, many other DT_'s, IFTODT.

Only application identifiers beginning with d_ or ending with _t are
reserved for <dirent.h> (they shall not be declared or defined for the
application).

FreeBSD's <sys/types.h> also fails to confrom to POSIX.  Even if
_POSIX_SOURCE is defined, it #defines many application identifiers:

	BIG_ENDIAN, BYTE_ORDER, HTONL, HTONS, LITTLE_ENDIAN
	NTOHL,  NTOHS, PDP_ENDIAN, htonl, htons, ntohl, ntohs.

and it declares one system identifier that doesn't belong here:

	lseek.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199607240811.SAA16182>