Implement pub support for enums, and also anonymous enums declared in-place. Also give the cdr of a `pub' form the form's own location, so a error about what follows `pub' can say where it was written
27 lines
776 B
Scheme
27 lines
776 B
Scheme
;;; Uses the greet module. Build both, then link them:
|
|
;;;
|
|
;;; ./sexc example/greet.sex -c -o greet.o
|
|
;;; ./sexc example/greet-app.sex -o greet-app -- greet.o
|
|
;;;
|
|
;;; `(import greet)' pastes greet's public declarations here: `greet'
|
|
;;; as a prototype and `greet-count' as an extern. Both keep external
|
|
;;; linkage, so they refer to the one definition in greet.o rather than
|
|
;;; to private copies.
|
|
;;;
|
|
;;; Also check that import populates type-database, by means of
|
|
;;; describe-fields macro, which should work on imported type.
|
|
|
|
(include stdio.h)
|
|
|
|
(import greet)
|
|
|
|
(pub fn main () int
|
|
(greet "world")
|
|
(greet "sex")
|
|
(printf "%d greetings\n" greet-count)
|
|
(describe-fields greeting)
|
|
(printf "\n")
|
|
(var m (enum mood) grumpy)
|
|
(printf "mood %d\n" m)
|
|
(return 0))
|