- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I want to define a nested Types, like
type TUnit
integer uni_type
type(UList) sub_list ! sub-unit-list
type(UList) dia_list ! Dialog list
end type
type ULitem
type(ULitem),pointer:: prev
type(ULitem),pointer:: next
type(TUnit) elem
end type
type UList
type(ULitem), pointer :: top ! top of the list
type(ULitem), pointer :: bot ! bottom of the list
integer ListSize ! number of items in the list
end type
But the compiler says that Ulist is not defined. How can I tell the compiler, that, that's a nested definition. ?
type TUnit
integer uni_type
type(UList) sub_list ! sub-unit-list
type(UList) dia_list ! Dialog list
end type
type ULitem
type(ULitem),pointer:: prev
type(ULitem),pointer:: next
type(TUnit) elem
end type
type UList
type(ULitem), pointer :: top ! top of the list
type(ULitem), pointer :: bot ! bottom of the list
integer ListSize ! number of items in the list
end type
But the compiler says that Ulist is not defined. How can I tell the compiler, that, that's a nested definition. ?
1 솔루션
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
The standard requires that if the component is not a POINTER, that "the declaration-type-spec in the component-def-stmt shall be CLASS(*) or shall specify an intrinsic type of a previously defined derived type" (emphasis mine)
If you add POINTER to the components in type TUnit, it compiles ok. This of course changes the meaning of the code, but you'll have to adjust for that.
링크가 복사됨
6 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
The standard requires that if the component is not a POINTER, that "the declaration-type-spec in the component-def-stmt shall be CLASS(*) or shall specify an intrinsic type of a previously defined derived type" (emphasis mine)
If you add POINTER to the components in type TUnit, it compiles ok. This of course changes the meaning of the code, but you'll have to adjust for that.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Alternatively, move the declaration of UList so that it is the first type declared. In your example all its components of user-defined type are already POINTERS.
There was a problem with the initial release of 11.1 (or maybe it was 11.0?) at one stage that caused fatal errors when presented with similar forward references, but that problem does not appear to be in the current releases.
There was a problem with the initial release of 11.1 (or maybe it was 11.0?) at one stage that caused fatal errors when presented with similar forward references, but that problem does not appear to be in the current releases.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
That won't work because one of the components of the second type is a non-pointer reference to the third. I had the same thought...
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Did the example get edited? As it appears now the order UList, TUnit, ULitem seems to compile ok with 11.1.046 without poking in any additional POINTER attributes.
Though I will note that me failing to count to three or thereabouts correctly did cause some rather significant issues for some code I wrote recently, so those around me have learned to take everything I say with a large grain of salt...
Though I will note that me failing to count to three or thereabouts correctly did cause some rather significant issues for some code I wrote recently, so those around me have learned to take everything I say with a large grain of salt...
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Quoting - IanH
Did the example get edited? As it appears now the order UList, TUnit, ULitem seems to compile ok with 11.1.046 without poking in any additional POINTER attributes.
Though I will note that me failing to count to three or thereabouts correctly did cause some rather significant issues for some code I wrote recently, so those around me have learned to take everything I say with a large grain of salt...
Though I will note that me failing to count to three or thereabouts correctly did cause some rather significant issues for some code I wrote recently, so those around me have learned to take everything I say with a large grain of salt...
>>Though I will note that me failing to count to three or thereabouts correctly...
Ian, I've heard that chickens are afflicted with the same problems. They can only count up to three. You can remove eggs from their nests without them noticing until the nest has three. Then upon removal (reduction from 3 to 2) they take notice.What does this say about us programmers?
Jim Dempsey
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Quoting - jimdempseyatthecove
>>Though I will note that me failing to count to three or thereabouts correctly...
Ian, I've heard that chickens are afflicted with the same problems. They can only count up to three. You can remove eggs from their nests without them noticing until the nest has three. Then upon removal (reduction from 3 to 2) they take notice.What does this say about us programmers?
Jim Dempsey
That we came first :-)
Les