小记一下
c 基本不改:无 name mangling,函数名 == 符号名,仅受平台 ABI 影响(如 Windows 可能 _foo,Unix/Linux 通常 foo)
c++ 一定会改名:
- 比如 clang/gcc:foo-> _Z3fooi
- _Z:C++ mangling 前缀
- 3foo:函数名 foo(长度 3)
- i:参数类型 int
c++ 如果需要混合编程 ISO_C_BINDING:
extern "C" void foo(int a);
fortran 程序:
- 普通子程序:foo->foo_
- 模块中的子程序:
比如:
module m
contains
subroutine foo(a)
end subroutine
end module__m_MOD_foo
fortran 如果混合编程 ISO_C_BINDING:
subroutine foo(a) bind(C, name="foo")
use iso_c_binding
integer(c_int), value :: a
end subroutine