I want to write a FFI for printf
function of C in Chez Scheme using foreign-procedure
. But I cannot figure out what I should put as the signature, since the last argument in printf
function is a variadic argument. Here's my code:
(import (chezscheme))
(define (print-format)
(foreign-procedure "printf"
(string void*) int)) ;; <-- Here, the type format is "(arg arg ...) ret"
(print-format "Hello, %s!" "Ryan")
I have tried this as well to no avail:
(define (print-format . args)
(foreign-procedure "printf"
(string args) int))
This is not working either:
(define (print-format)
(foreign-procedure "printf"
(string ...) int))
How do you specify variadic arguments in function signature for foreign-procedure
?