Как правильно определить эту рекурсивную структуру C в Fortran?
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
.