declare a record's typedef ahead of its struct
It came after, so a record pointing at itself, (next (* node)), named a type C had not been told of yet.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
(input)
|
||||
(output "p 3 4 / n 7 zoe / area 12 / sizes 8 8")
|
||||
(output "p 3 4 / n 7 zoe / area 12 / sizes 8 8"
|
||||
"chain 1 2")
|
||||
(return 0)
|
||||
|
||||
;;; A record is a struct that also names itself, so the bare name
|
||||
@@ -18,6 +19,10 @@
|
||||
|
||||
(struct raw ((a int) (b int)))
|
||||
|
||||
;;; A record naming itself in its own fields: the name is a type before
|
||||
;;; the fields are
|
||||
(record node ((value int) (next (* node))))
|
||||
|
||||
(fn shift ((p (* point)) (dx int) (dy int)) void
|
||||
(+= (. p x) dx)
|
||||
(+= (. p y) dy))
|
||||
@@ -43,4 +48,8 @@
|
||||
(. p x) (. p y) (. n id) (. n first-name)
|
||||
(area [ps 0])
|
||||
(sizeof point) (sizeof (struct raw)))
|
||||
|
||||
(var tail node #(node : 2 NULL))
|
||||
(var head node #(node : 1 (& tail)))
|
||||
(printf "chain %d %d\n" (. head value) (. head next value))
|
||||
(return (+ (. [ps 1] x) (- (. r a) 1))))
|
||||
|
||||
Reference in New Issue
Block a user