[J3] BIND(F)?
Clune, Thomas L. (GSFC-6101)
thomas.l.clune at nasa.gov
Thu Jun 23 21:35:35 UTC 2022
I’m sure this question has come up before, but I can’t recall if it was dismissed as unworkable, or merely not worthwhile.
I have a project that is starting to heavily use shared object libraries (aka DSOs’). The interfaces are all in Fortran. To use the DSO we must pass the global name of the called procedure to dlsym(). One might hope that declaring the DSO procedure with BIND(C) would allow us to specify the global name in a portable manner, but … the interface is not C interoperable. (In theory it might be made so, but the underlying framework is huge and no-one is going to rewrite it to use C interoperable types all the way down.)
We’ve mitigated the name-mangling by putting the main DSO procedure outside of the module that would otherwise be its proper home. At the moment most/all extant compilers with default compilation flags will then make a global name that is the lower case version of the Fortran name with an underscore. So at least this is nominally portable, but not guaranteed to be.
It seems a natural request then to allow a procedure to be declared BIND(F, name=”…”) The procedure could then even live inside of a module (amusingly allowing the module to have no PUBLIC entities).
Is this unworkable for reasons that I don’t understand? Low priority? Or maybe a very small feature that could be put into 202y?
Again apologies for asking a question that has undoubtedly been asked before (possibly by _me_).
Cheers,
* Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220623/4f91938c/attachment.htm>
More information about the J3
mailing list