look past comments in a public form's header

This commit is contained in:
2026-09-21 00:56:26 +03:00
parent 05bab57867
commit 1195e5c191
7 changed files with 38 additions and 19 deletions

View File

@@ -11,6 +11,9 @@
# It also checks what only a second translation unit can check: that an
# imported type reaches the type database, by expanding a macro that
# reads the imported struct's fields.
#
# The public forms carry comments in their headers, which the reduction
# to a prototype and to an extern both have to look past.
SEXC ?= ../../sexc

View File

@@ -7,7 +7,11 @@
(include stdio.h)
(pub var greet-count int 0)
(pub var greet-count ;; a comment in the header of a public form is
;; not part of it: what the importer is given has
;; to be `extern int greet-count', not a form
;; counted off by one
int 0)
(pub struct greeting ((text (* const char)) (times int)))
@@ -23,7 +27,8 @@
(lambda (name field-type)
`(printf "%s " ,(symbol->string name))))))
(pub fn greet ((name (* const char))) void
(pub fn greet ;; ...and here the prototype would lose its return type
((name (* const char))) void
(++ greet-count)
(printf "hello, %s\n" name))