- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Anyone know where these error codes are documented? I get either 2 or 128 based on an unknown difference. Which one is an error and which one (if either) means I reached the end of the directory?
Thanks
Thanks
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
POSIX error codes are system-dependent ---although the first thirty-something ones tend to be the same from one system to another.
The errno.h header (which, in my system, is located in /usr/include/asm-generic) can help you determine the exact error... Or you could just call the strerror function and get the actual error string, e.g.:
[fortran]use iso_c_binding
implicit none
interface
function mystrerror(errnum) bind(C, NAME = 'strerror')
import
type(C_PTR) :: mystrerror
integer(C_INT), value :: errnum
end function
end interface
integer :: i
type(C_PTR) :: ptr
character(KIND=C_CHAR), pointer :: cstr(:)
character(255) :: fstr
ptr = mystrerror(128_C_INT)
call C_F_POINTER(ptr, cstr, [255])
fstr = ''
do i = 1, SIZE(cstr)
if (cstr(i) == C_NULL_CHAR) exit
fstr(i:i) = cstr(i)
enddo
print '("the string for error #", I0, " is: ", A)', 128, TRIM(fstr)
end
[/fortran] Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the PXF calls are wrappers to Posix calls. So
man 3 readdir
will give you the info you need, along with /usr/include/dirent.h
ron
man 3 readdir
will give you the info you need, along with /usr/include/dirent.h
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
POSIX error codes are system-dependent ---although the first thirty-something ones tend to be the same from one system to another.
The errno.h header (which, in my system, is located in /usr/include/asm-generic) can help you determine the exact error... Or you could just call the strerror function and get the actual error string, e.g.:
[fortran]use iso_c_binding
implicit none
interface
function mystrerror(errnum) bind(C, NAME = 'strerror')
import
type(C_PTR) :: mystrerror
integer(C_INT), value :: errnum
end function
end interface
integer :: i
type(C_PTR) :: ptr
character(KIND=C_CHAR), pointer :: cstr(:)
character(255) :: fstr
ptr = mystrerror(128_C_INT)
call C_F_POINTER(ptr, cstr, [255])
fstr = ''
do i = 1, SIZE(cstr)
if (cstr(i) == C_NULL_CHAR) exit
fstr(i:i) = cstr(i)
enddo
print '("the string for error #", I0, " is: ", A)', 128, TRIM(fstr)
end
[/fortran]
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page