For the record, you can try to “protect” yourself from name mangling issues by the disciplined use of C preprocessor macros. Take a look at how NLopt solves this: nlopt/f77api.c at 4a0e93ce177dc8bf0f7cf7e3f3e52521b0553958 · stevengj/nlopt · GitHub
The preprocessing is spread over three files in total, but would still fail if a new name-mangling scheme were introduced. Using bind(c)
however, you can write a fully compatible and type-safe interface: GitHub - grimme-lab/nlopt-f: Fortran bindings for the NLopt library. (note in this case, the wrapping goes in the “other” direction, Fortran calling C, but the issues are the same)