Query about <dirent.h>
Moderator, John S. Quarterman
std-unix at longway.TIC.COM
Fri Nov 24 21:30:00 AEST 1989
From: Andy Tanenbaum <uunet!cs.vu.nl!ast>
In article <438 at longway.TIC.COM> gwyn at brl.arpa (Doug Gwyn) writes:
>You, the implementer, could manually replace that NAME_MAX with the
>appropriate value (perhaps found by inspecting <limits.h>).
It is true I could just put 14 there, or #define it to be _NAME_MAX in that
file, but that seems poor programming practice. If that constant ever gets
changed in <limits.h> but not in <dirent.h> disaster will strike.
>What I did in my implementation was to cheat:
> 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.
Is it legal to add a line
#include <limits.h>
in <dirent.h>?
Andy Tanenbaum (ast at cs.vu.nl)
Volume-Number: Volume 17, Number 69
More information about the Comp.std.unix
mailing list