Fortran でこの再帰的な C 構造体を定義する正しい方法は何ですか?
struct OPTION {
char option;
char *arg;
struct OPTION *next;
struct OPTION *previous;
};
私はこの Fortran コードを書きました:
module resources
use iso_c_binding
implicit none
type :: OPTION
character(c_char) :: option
character(c_char) :: arg
type(OPTION), pointer :: next
type(OPTION), pointer :: previous
end type OPTION
end module resources
bind(c)
これはコンパイルされますが、型定義が欠落しているため、間違っていると思います。type, bind(c) :: OPTION
gfortranを使用しようとすると、 Error: Component 'next' at (1) cannot have the POINTER attribute because it is a member of the BIND(C) derived type 'option' at (2)
.
そして、属性を保持type, bind(c) :: OPTION
して削除すると、.POINTER
Error: Component at (1) must have the POINTER attribute