look past comments in a public form's header

This commit is contained in:
2026-09-21 00:56:26 +03:00
parent 534e9ef56b
commit ee053e35c9
7 changed files with 45 additions and 29 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
"A greeting to print."
@@ -25,7 +29,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
"Print a greeting for NAME."
(++ greet-count)
(printf "hello, %s\n" name))