Yaroslav Kavenchuk wrote:
Hmm, sprintf under mingw not work with double/single-float without any varargs:
check:
(ffi:def-call-out sprintf-int (:name "sprintf") (:return-type nil) (:library :default) (:language :stdc) (:arguments (out-str (ffi:c-ptr (ffi:c-array-max character 256)) :out :alloca) (fmt ffi:c-string) (n ffi:int))) SPRINTF-INT (sprintf-int "%d" 100) "100"
double:
(ffi:def-call-out sprintf-double (:name "sprintf") (:return-type nil) (:library :default) (:language :stdc) (:arguments (out-str (ffi:c-ptr (ffi:c-array-max character 256)) :out :alloca) (fmt ffi:c-string) (n ffi:double-float))) SPRINTF-DOUBLE (sprintf-double "%.2f" 3.14d0) "X""
Perhaps, reason in it?
Thanks!
Oops, if use libintl_sprintf instead of sprintf - all works:
[5]> (ffi:def-call-out li-sprintf-double (:name "libintl_sprintf") (:return-type nil) (:library :default) (:language :stdc) (:arguments (out-str (ffi:c-ptr (ffi:c-array-max character 256)) :out :alloca) (fmt ffi:c-string) (n ffi:double-float))) LI-SPRINTF-DOUBLE [6]> (li-sprintf-double "%.2lf" 3.14d0) "3.14" [7]> (li-sprintf-double "%.2f" 3.14d0) "3.14"
Hmm. I do not know why sprintf function does not work in clisp/mingw.
Thanks!