[Fortran] 纯文本查看 复制代码
module cprog
interface
subroutine SUBA(a)
!DEC$ ATTRIBUTES C, ALIAS:'_sub1' :: SUBA
integer :: a
!DEC$ ATTRIBUTES REFERENCE :: a
end subroutine
subroutine SUBB(a)
!DEC$ ATTRIBUTES C, ALIAS:'_sub2' :: SUBB
integer :: a
!DEC$ ATTRIBUTES VALUE :: a
end subroutine
end interface
end module cprog
program main
use cprog
implicit none
integer(8) :: a=10
call SUBA(a)
call SUBB(a)
stop
end program
[C++] 纯文本查看 复制代码
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
void sub1(int *num)
{
printf("%d\n",*num);
}
void sub2(int num)
{
printf("%d\n",num);
}
#ifdef __cplusplus
}
#endif
[Fortran] 纯文本查看 复制代码
module cprog
interface
subroutine SUBA(a) Bind(C,Name="sub1")
integer(8) :: a
end subroutine
subroutine SUBB(a) Bind(C,Name="sub2")
integer(8) , value:: a
end subroutine
end interface
end module cprog
program main
use cprog
implicit none
integer(8) :: a=10
call SUBA(a)
call SUBB(a)
stop
end program