This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: iostat
On Wed, Aug 23, 2006 at 09:42:50AM +0300, Erik Edelmann wrote:
>
> What about assigning the value of errno to iostat, and then if the user
> wants to know what an error code means on his system, he can do
> something like
>
>
> #include <stdio.h>
> int main () { puts(strerror(<the error code>)); return 0; }
>
>
> It requires some basic C knowledge of course, so it's not an ideal
> solution, but if someone is desperate enough, it's still doable.
>
If we do this (and I'm not necessarily opposed to better error
messages), then I think we should add new (nonstandard) intrinsic
procedure, say, iostat_to_msg(). This would be much easier to
document, and avoids having to list errno values in gfortran.texi,
and does require gfortran user to gravel through C code/headers.
program test
integer ios
character(len=80) msg
open(unit=1,file='yada',iostat=ios)
if (ios /= 0) then
call iostat_to_msg(ios, msg)
end if
end program test.
Where we have
interface
subroutine iostat_to_msg(ios, msg)
integer, intent(in) :: ios
character(len=*), intent(out) :: msg
end subroutine iostat_to_msg
end interface
and
void
iostat_to_msg(GFC_INTEGER_4 *iostat, char *msg, gfc_charlen_type len)
{
strncpy(msg, strerror(*iostat), len-1);
}
--
Steve