- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page