(j3.2006) Interesting F2003-ism

Bill Long longb
Thu Feb 22 13:53:26 EST 2007



Aleksandar Donev wrote:

>Andy Vaught wrote:
>
>  
>
>>I will start the process by not
>>implementing the restriction on binding-labels in g95...
>>    
>>
>Good, since that restriction makes perfectly sensible programs illegal 
>too, most notably my favorite example:
>
>module A
>   interface
>     subroutine p_A(f, a) bind(c, name='p')
>       type(c_ptr) :: f
>       integer, value :: a
>     end subroutine p1
>end module
>
>module B
>   interface
>     subroutine p_B(f, a) bind(c, name='p')
>       type(c_ptr) :: f
>       integer, value :: a
>     end subroutine p1
>end module
>
>Note that here one is merely giving two different Fortran names in two 
>*distinct* modules to the same interface and same C procedure.
>  
>

Bind(c) does not in any way imply that the procedure is written in C.  
Indeed, in a large class of cases, the routine is written in Fortran.

Suppose, for the example above, the user writes (in Fortran) subroutines 
p_A and p_B, and writes another subprogram that uses both modules and 
then calls P.  What routine gets called?  How does the proposed 
"extension" in g95 propose to deal with this?  Just rely on the loader 
to produce a duplicate symbol error?  The rules in 16 are, in part, 
designed to avoid loader errors.

We have discussed a new feature that would add a LANG= clause to 
BIND(...) that would let the user explicitly say that the procedure was 
written in C. Or Fortran.  I think this would solve the problem.  But it 
came up too late to make the f08 standard.  A likely candidate for f13, 
I suspect.

Cheers,
Bill




-- 
Bill Long                                   longb at cray.com
Fortran Technical Support    &              voice: 651-605-9024
Bioinformatics Software Development         fax:   651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120

            

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3.scs.gmu.edu/pipermail/j3/attachments/20070222/876455a0/attachment.html 



More information about the J3 mailing list