[J3] Is BIND (C [ , NAME = scalar-default-char-constant-expr ]) where scalar-default-char-constant-expr has zero length legal?
Daniel C Chen
cdchen at ca.ibm.com
Tue Jan 8 15:20:50 EST 2019
Hi Bill and Vipul,
It is down to if "subroutine foo() bind(c, name='')" should be treated as:
1. subroutine foo() bind(c), or
2. subroutine foo()
BIND attribute is part of the characteristic of a procedure, so option 1
and options 2 are significantly different.
It seems option 1 is preferred, and I think it makes more sense too. The
problem is I couldn't find any wording in the standard that makes it clear.
Thanks,
Daniel
XL Fortran Development, Fortran Standard Representative
IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
From: Vipul Parekh via J3 <j3 at mailman.j3-fortran.org>
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Vipul Parekh <parekhvs at gmail.com>
Date: 01/08/2019 03:01 PM
Subject: Re: [J3] Is BIND (C [ , NAME =
scalar-default-char-constant-expr ]) where
scalar-default-char-constant-expr has zero length legal?
Sent by: "J3" <j3-bounces at mailman.j3-fortran.org>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20190108/13d9dc4b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20190108/13d9dc4b/attachment.gif>
More information about the J3
mailing list