(j3.2006) Binding label and bind(c) procedure name scopes
Malcolm Cohen
malcolm
Tue May 26 02:23:22 EDT 2015
<<<
Case 1:
Interface
Subroutine sub() Bind(C, name = "csub")
End
Subroutine csub() Bind(C, name = "sub")
End
End interface
End
Is this code standard conforming? It seems fine to me, but the standard seems
disallow it as 16.3.1p2 [474:13-18]
>>>
I do not see anything wrong here, because the global identifier that is the
binding label is not used in the scope. The global identifiers that are binding
labels being csub and sub. The character string literals are character string
literals, they are not global identifiers. Within the scope only the local
identifiers sub and csub are used. So no problem.
<<<
Case 2:
Module m
Contains
Subroutine sub1()
Interface
Subroutine s() Bind(C, name="csub")
End
End interface
End
Subroutine sub2()
Interface
Subroutine s() Bind(C, name="sub")
End
End interface
End
End module
Is this code legal? Again, it seems fine to me, but it seems disallowed by the
standard at [474:26]
"An entity of the program shall not be identified by more than one binding
label."
>>>
Yes, this is invalid and rejected by some existing compilers. This has been
discussed in the past.
If we want to allow this we are going to have to reword 16.2p1 much much more
carefully; for a start, so that external procedures with binding labels don't
appear twice in the list, to avoid confusion. I am sympathetic to such a
request.
<<<
Case 3:
Module m
Contains
Subroutine sub1()
Interface
Subroutine s() Bind(C, name="sub")
End
End interface
End
Subroutine sub2()
Interface
Subroutine s() Bind(C, name="sub")
End
End interface
End
End module
A slighly modification from Case 2 that the binding labels are also the same,
and again, Is this code legal?
>>>
I don't see why not. The external procedure S is described by two interface
blocks, both of which are consistent, including the binding label parts.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list