(j3.2006) A few constants from ISO_Fortran_env for C interop

Van Snyder Van.Snyder
Mon Oct 24 15:53:26 EDT 2011


On Mon, 2011-10-24 at 12:00 -0700, Bill Long wrote:
> Alternatively, a user-written module, that has a USE of
> ISO_Fortran_env, could be supplied that declared bind(c) variables
> that were initialized to these constants.  Then the C user could just
> reference the variables directly.   You might name them Fortran_stdout
> and Fortran_stderr, for example.

The variables aren't constants that a C function can use for
initialization.  So this is a little better than (or not quite as good
as, depending upon your viewpoint) using a BIND(C) subroutine to set the
values.

Fortran programmers have maybe been spoiled by having default
initialization.

I don't see enough C code to know how comfortable the average C
programmer is with instructions to call several initialization functions
before calling the one that does what he actually wants done.  Is it
common and tolerated, and recognized that failing to do the
initialization properly is a source for obscure bugs?





More information about the J3 mailing list