试试标准的 ISO_C_binding 用法:
[Fortran] 纯文本查看 复制代码 module ForLib
use , intrinsic :: ISO_C_Binding
implicit none
contains
subroutine sub_test(ps,ii,pia,oo) Bind(C,Name="sub_test")
type(C_PTR) , value :: ps , pia
character(len=512) , pointer :: s
integer , pointer :: ia(:)
integer :: ii,oo
call c_f_pointer( pia , ia , [100] )
call c_f_pointer( ps , s )
oo = len(s)+sum(ia)-ii
write(789,*) s
end subroutine sub_test
end module ForLib
[C] 纯文本查看 复制代码 #pragma optimize("g",off)
void sub_test(char *, int *, int *, int *);
__declspec(dllexport) void ccf_test(int *oo){
int ooa = 64;
char s[512] = "helllo,world";
int ii = 32;
int ia[100];
for (int i = 0; i < 100; i++){
ia[i]=3;
}
oo = &ooa;
sub_test(&s, &ii, &ia[0], oo);
} |