extern
を使用してinterface
をCにインポートするにはどうすればよいですか?FortranからC言語へのインターフェイスモジュールプロシージャのインポート
は、私は次のFortranモジュールがあるとします。
!swapper module
module swapper
interface swap
module procedure swap_r, swap_i, swap_c
end interface
contains
!subroutine implementations here:
!swap_r takes two double precision as argument
!swap_i takes two integers as argument
!swap_c takes two characters as argument
end module swapper
は、その後、私はちょうど、Cに次の操作を行うことができますか?
またextern "C" void __swapper_MOD_swap(double*, double*)
extern "C" void __swapper_MOD_swap(int*, int*)
extern "C" void __swapper_MOD_swap(char*, char*)
、私は排他的にこれを行うことが、唯一の倍精度数でswap
を呼び出すことを約束している場合?
extern "C" void __swapper_MOD_swap(double*, double*)
これはおそらくあなたを助けます。http://docs.cray.com/books/S-2179-52/html-S-2179-52/ppgzmrwh.html – Stargateur
Cにはジェネリックはありませんが、C++にはジェネリックがあります。そして、Cに 'extern" C "'はありません。あなたは実際にC++を使用していますか? –
これには「INTERFACE」に関する詳細があります:https://people.sc.fsu.edu/~jburkardt/f_src/f90_calls_c++/f90_calls_c++。html – QuantumDot