Exploring ISO_C_BINDING and type-bound procedures

Sorry, but your entire approach is doomed to failure. First, a bugaboo of mine - the C interoperability features are not defined by intrinsic module ISO_C_BINDING, and I wish people would stop referring to the module when they mean the interop features. The module is helpful but not a requirement to use the C interop features.

Never, ever use “renaming” to work around such things as module procedure global names. You can declare that module-contained procedures have the BIND(C) attribute, at which point you can specify their external name, or use the default which is downcased and then any decoration the “companion C processor” would use is applied.

As for type-bound procedures and polymorphic (CLASS) entities - these are simply not interoperable, so don’t fool yourself into thinking you can make them so. Maybe you can tie yourself in knots with a particular compiler and get some simple examples to work, but it would be a huge disservice to use this as an example for others.

2 Likes