forked from alex-eg/sex
'#+' and '#-' introduce conditional compilation: the form that follows is kept only when the feature expression is true, and otherwise is read and thrown away. An expression is a feature name, or and / or / not of them. They are read time, not compile time. Default features are the host's software-version, software-type and machine-type as CHICKEN reports them, plus what --features flag adds.
24 lines
673 B
Scheme
24 lines
673 B
Scheme
(compilation "--features=test-on")
|
|
(input)
|
|
(output "selected" "on" "and-not")
|
|
(return 0)
|
|
|
|
;;; #+ and #- pick what the compiler gets to see. `test-on' is handed
|
|
;;; to sexc by the (compilation ...) form above, so this program reads
|
|
;;; the same way on every platform.
|
|
|
|
(include stdio.h)
|
|
|
|
#+test-on (define GREETING "on")
|
|
#-test-on (define GREETING "off")
|
|
|
|
#-test-on (pub fn main () int (puts "the whole function is dropped") (return 1))
|
|
|
|
(pub fn main () int
|
|
;; ...and inside a form, not only at toplevel
|
|
(puts #+test-on "selected" #-test-on "rejected")
|
|
(puts GREETING)
|
|
#+(and test-on (not test-off)) (puts "and-not")
|
|
#-test-on (puts "never printed")
|
|
(return 0))
|