[J3] dumb question about module use not inheriting into interfaces

Gary Klimowicz gak at dancingbear.dev
Sat Aug 27 02:14:07 UTC 2022


On Aug 26, 2022, at 12:37, Vipul Parekh via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> module confused
> 
> ..
> 
>     interface, bind(C)  !<-- *
> 
> #include "foo.h"
> 
>     end interface
> 
> ..
> 
> end module
> 

I don't think this would work unless "foo.h" only contained a single definition, right?

And the other alternative is even more difficult.
> module confused
> 
> ..
> 
>     interface, bind(C)  !<-- *
> 
>        void foo(float *);
> 
>     end interface
> 
> ..
> 
> end module
> 

This would require an interface to the companion processor to parse the C code fragment and return to the Fortran processor the Fortran definition of the interface (or an AST-like representation of it). I don't see the Clang folks saying this is in their job description.

This interface would also have to know about all the types used in the C fragment and how to map them to Fortran types, I presume. Would you expect this to include adding new types to the Fortran interface to accommodate those found in the C? What would you expect to happen if we had something like this?

module confused

..

    interface, bind(C)  !<-- *

       #include "mytype.h"

       mytype foo(float *);

    end interface

..

end module


I might be confused by your suggestion, Vipul, but I don't see how anything like this is realistically possible with current compiler technology.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220826/5d425e9d/attachment-0001.htm>


More information about the J3 mailing list