ASM allowed in Fortran? and OpenDir?

FX Coudert fxcoudert@gmail.com
Tue Aug 7 08:45:00 GMT 2007


> type, bind(C) :: dirent
>   integer(c_long)    :: d_ino
>   integer(c_long)    :: d_off; ! __off_t, check size
>   integer(c_short)   :: d_reclen
>   character(len=1,kind=c_char) :: d_name(256)
> end type

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 */
           };

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...

FX



More information about the Fortran mailing list