This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ASM allowed in Fortran? and OpenDir?


on my linux box, there is a dirent and a dirent64. the dirent struct matches Tobias's, and when used in the modified version of his code, works as expected. the dirent64 matches the definition provided by FX. the user will probably need to figure out what their's is by looking in dirent.h. of course, this is not the most portable way this could be done.

Chris

On Tue, 7 Aug 2007, FX Coudert wrote:

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]