1
0
forked from alex-eg/sex

force c89 pedantic compilation mode

This commit is contained in:
2025-08-21 18:15:48 +03:00
committed by Pavel Kulyov
parent 63918d23c0
commit d5e443a72c
2 changed files with 13 additions and 9 deletions

View File

@@ -1,6 +1,5 @@
(include stdlib.h) (include stdlib.h)
(include stddef.h) (include stddef.h)
(include stdbool.h)
(include stdio.h) (include stdio.h)
(chicken-import srfi-1 brev-separate) ; list routines, e.g. fold (chicken-import srfi-1 brev-separate) ; list routines, e.g. fold
@@ -16,7 +15,7 @@
((const char *) c) ((const char *) c)
((fn bool ((bool val))) not))) ((fn bool ((bool val))) not)))
(var foo f #((= .a-field 1.2))) (var foo f)
(list-T int) (list-T int)
(make-list-T int #f) (make-list-T int #f)
@@ -26,7 +25,7 @@
(extern fn void puk ((int a) (float b))) (extern fn void puk ((int a) (float b)))
(fn int bar () (return ,(imports-test 10 20 30))) (fn int bar () (return ,(imports-test 10 20 30)))
(pub fn void baz () true) (pub fn bool baz () (return true))
(extern var int i) (extern var int i)
(var int j) (var int j)
@@ -34,15 +33,15 @@
(pub fn int main () (pub fn int main ()
(var (* list-int) l (make-list-int)) (var (* list-int) l (make-list-int))
(printf "Size of the list: %zu\n" (length-list-int l)) (printf "Size of the list: %lu\n" (length-list-int l))
(add-value-list-int l 3) (add-value-list-int l 3)
(add-value-list-int l 4) (add-value-list-int l 4)
(printf "Size of the list: %zu\n" (length-list-int l)) (printf "Size of the list: %lu\n" (length-list-int l))
(list-for-each list-int l int v (list-for-each list-int l int v
(printf "%d " v)) (printf "%d " v))
(printf "\n") (printf "\n")
(printf "Size of the list: %zu\n" (length-list-int l)) (printf "Size of the list: %lu\n" (length-list-int l))
(printf "%p\n" l->next) (printf "%p\n" (cast void* l->next))
(return 0)) (return 0))
(pub fn void print-list (((const list-int) *l)) (pub fn void print-list (((const list-int) *l))

View File

@@ -1,7 +1,8 @@
(declare (unit sexc) (declare (unit sexc)
(uses fmt-c (uses fmt-c
sex-macros sex-macros
sex-modules)) sex-modules
sex-types))
(include "utils.macros.scm") (include "utils.macros.scm")
@@ -44,6 +45,10 @@
((@) 'vector-ref) ((@) 'vector-ref)
((include) '%include) ((include) '%include)
((cast) '%cast) ((cast) '%cast)
;; uh things we do for c89 compatibility
((bool) 'int)
((true) 1)
((false) 0)
(else (else
(if (symbol? atom) (if (symbol? atom)
(unkebabify atom) (unkebabify atom)
@@ -288,7 +293,7 @@
(emit-c sex-forms))) (emit-c sex-forms)))
(call-with-values (call-with-values
(lambda () (lambda ()
(process compiler (append (list temp-c-out "-o" out-file) (process compiler (append (list temp-c-out "-o" out-file "-std=c89" "-pedantic")
(if (get-arg args 'compile-object #f) (if (get-arg args 'compile-object #f)
(list "-c") (list "-c")
(list)) (list))