Query about <dirent.h>
Chuck Karish
karish at forel.stanford.edu
Tue Nov 28 05:35:08 AEST 1989
From: karish at forel.stanford.edu (Chuck Karish)
In article <442 at longway.TIC.COM> gwyn at brl.arpa (Doug Gwyn) wrote:
>In article <441 at longway.TIC.COM> Andy Tanenbaum <uunet!cs.vu.nl!ast> writes:
>-> char d_name[1];
>-What happens when a program allocates a struct dirent in a program? The
>-compiler will not allocate enough storage and it will crash when used.
>
>That's what happens when programmers assume things that are not promised
>by the standards.
This is spelled out in the rationale (B.5.1.1).
>-Is it legal to add a line
>-#include <limits.h>
>-in <dirent.h>?
>
>NO.
A citation would be more useful here than this proclamation.
I haven't been able to find anything in the 1003.1 documents that would
prohibit this.
The form of a header is defined by the implementation. There are many
places in the Standard where it is required that a particular
identifier be available when a particular header is #included, but I
haven't found any that require that identifiers not be visible when the
headers to which they are assigned have not been #included.
Portable application code must #include headers as listed in the
function descriptions in the standard, if only for compatibility
with implementations that don't support ANSI C. It will be easier
to identify non-portable code under implementations that refrain from
#including, for example, <sys/types.h> in <stat.h>.
Chuck Karish karish at mindcraft.com
(415) 323-9000 karish at forel.stanford.edu
Volume-Number: Volume 17, Number 75
More information about the Comp.std.unix
mailing list