ASM allowed in Fortran? and OpenDir?
Tobias Burnus
burnus@net-b.de
Tue Aug 7 09:05:00 GMT 2007
Hi Fx,
FX Coudert wrote:
> According to my linux man page, you forgot the d_type member:
> struct dirent {
> ino_t d_ino; /* inode number */
> off_t d_off; /* offset to the next dirent */
> unsigned short d_reclen; /* length of this record */
> unsigned char d_type; /* type of file */
> char d_name[256]; /* filename */
> };
Could well be, but it fails already much earlier:
dir = opendir (&"."[1]{lb: 1 sz: 1}, 1);
returns a NULL pointer whereas C's
dir = opendir ((const char *) (char *) ".");
returns a non-NULL pointer.
(errno is probably not the right variable; in C errno is a macro which
returns "*__errno_location ()".)
> And, the whole point of this is: there is no portable way to do this.
> POSIX only says "the structure dirent which includes the following
> members: ino_t d_ino, file serial number; char d_name[], name of
> entry". This information is enough to be used in C, but not in Fortran
> which needs to know the complete layout of the structure. This is one
> of the reasons why I'm not convinced that ISO_C_BINDING leads to
> enhanced portability...
It does, but by far it does not solve all problems; if one controls both
parts of the program - the C and the Fortran part - then it helps a lot.
For opendir/readdir one should probably write a C wrapper.
Tobias
More information about the Fortran
mailing list