Fortran Coder

标题: DLL调用中的 common 传递 [打印本页]

作者: Alouis    时间: 2015-7-10 10:09
标题: DLL调用中的 common 传递
源程序:
[Fortran] 纯文本查看 复制代码
program ex0811
implicit none
  integer :: a,b
  common /group1/ a
  common /group2/ b
  a=1
  b=2
  call ShowGroup1()
  call ShowGroup2()
  stop
end
subroutine ShowGroup1()
implicit none
  integer :: num1
  common /group1/ num1
  write(*,*) num1
  return
end

subroutine ShowGroup2()
implicit none
  integer :: num1
  common /group2/ num1
  write(*,*) num1
  return
end

我想把后面的子函数做成DLL
我的方法是:
[Fortran] 纯文本查看 复制代码
subroutine ShowGroup1()
!DEC$ ATTRIBUTES DLLEXPORT :: ShowGroup1
implicit none
  integer :: num1
  common /group1/ num1
  write(*,*) num1
  return
end

subroutine ShowGroup2()
!DEC$ ATTRIBUTES DLLEXPORT :: ShowGroup2
implicit none
  integer :: num1
  common /group2/ num1
  write(*,*) num1
  return
end

最后调用的结果与源程序不一样,想问一下什么原因?
作者: fcode    时间: 2015-7-10 10:31
common 这东西并不能跨越 DLL 传递。
作者: Alouis    时间: 2015-7-10 11:04
fcode 发表于 2015-7-10 10:31
common 这东西并不能跨越 DLL 传递。

额,明白了,多谢




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2