[J3] Is BIND (C [ , NAME = scalar-default-char-constant-expr ]) where scalar-default-char-constant-expr has zero length legal?

Vipul Parekh parekhvs at gmail.com
Tue Jan 8 14:59:30 EST 2019


On Tue, Jan 8, 2019 at 11:06 AM Daniel C Chen via J3
<j3 at mailman.j3-fortran.org> wrote:
>
> .. the standard doesn't specify what if the scalar-default-char-constant-exprhas zero length.
>
> Question: Should it be treated
> 1. as if the NAME specified is not specified or
> 2. the compiler should ignore the BIND attribute all together?
>

Hi Daniel,

You must have seen Jon's and Bill's responses.  Just for your
reference, here's a (related?) thread from comp,lang.fortran on NAME
specifier with BIND attribute:
https://groups.google.com/d/msg/comp.lang.fortran/x3hMN4chYtc/ewskOS5oDAAJ


On Tue, Jan 8, 2019 at 11:31 AM Steidel, Jon L via J3
<j3 at mailman.j3-fortran.org> wrote:
> ..
> Both compilers compile without error or warning, and fail in the link/load step with an undefined reference to “foo” or “foo_”.  So it looks like the Fortran name is used when NAME= is a zero length string.
> ..

Hi Jon,

Interestingly and (dare I say!) correctly and thankfully, your example
compiled using Intel Fortran can be linked with the object created by
that same compiler toward this code on Windows x64 platform

subroutine foo( arg ) bind(C, name="foo")
   real arg
   print *, "foo: arg = ", arg
end subroutine

and executed to produce the following output:

 foo: arg =  1.000000

Regards,
Vipul


More information about the J3 mailing list