1.91 MB, 下载次数: 24
1.61 MB, 下载次数: 17
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
#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=3;
}
oo = &ooa;
sub_test(&s, &ii, &ia[0], oo);
}
fcode 发表于 2017-10-10 08:27
一般来说,定义得足够长就可以了。因为是虚参,所以并不会占用过多内存空间。
其意义就像:“我以为它有512 ...
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |