- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I'm trying to use the following declaration:
use ISO_C_BINDING
type(C_PTR) handle
COMMON /MyHandle/handle
This generates the following error:
Error: If a common-block-object is of a derived type, it must be of a sequence type (R549.f)
The Fortran help doc only gives an example of using the SEQUENCE statement inside a type definition block. Since C_PTR is defined in the ISO_C_BINDING module, how do I use SEQUENCE onthe C_PTR variableor is there a better solution for usinga C_PTRin a COMMON block?
Thanks,
Dick
링크가 복사됨
2 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Itwould be betterto have "handle" in a module rather than a common block, (even if it is the only item in it.) Especially as you are using modern Fortran.
Les
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
The standard says that if a COMMON block entity is of derived type, it must be a SEQUENCE type or have the BIND attribute. Type C_PTR has neither, though it is unclear to me whether it should have BIND(C) - I will ask about that.
In any event, as Les suggests, a better approach is this:
module mymod
use ISO_C_BINDING
type(C_PTR), BIND(C,NAME="_MyHandle") :: handle
end
The leading underscore is temporarily necessary until a compiler bug is fixed.
In any event, as Les suggests, a better approach is this:
module mymod
use ISO_C_BINDING
type(C_PTR), BIND(C,NAME="_MyHandle") :: handle
end
The leading underscore is temporarily necessary until a compiler bug is fixed.
