This is actually all fixed.
For reasons I have no idea why, they can be fixed via:
1) using "compile-file" instead of "compile-file-to-c & link-flat"
2) using cc-options: "-Wno-write-strings"
On Mon, Feb 23, 2009 at 11:38 PM, lowly coder lowlycoder@huoyanjinjing.comwrote:
Hi!
There are two compiler warnings I want to get rid of. Please enlighten me. (1) is from gcc, (2) is from gsc.
(1) this one deals with const char * vs char * if I try to do (pointer char), I get the following error: ~/test$ cat error1.scm; echo '-----'; gsc error1.scm; echo '-----'; gsc -link error1; gsi -e '(load "error1")' (c-declare #<<c-declare-end #include <stdio.h> void foo(const char* str) { fprintf(stderr, "printing: %s\n", str); } c-declare-end )
(define foo (c-lambda ((pointer char)) void "foo"))
(foo "hello world")
error1.c:45: warning: deprecated conversion from string constant to ?char*? error1.c:51: warning: deprecated conversion from string constant to ?char*? error1.c:51: warning: deprecated conversion from string constant to ?char*? error1.c:51: warning: deprecated conversion from string constant to ?char*? error1.c:191: warning: deprecated conversion from string constant to ?char*?
*** ERROR IN ##load -- (Argument 1) Can't convert to C pointer (foo "hello world")
now, if I use char-string instead, I get an annoying error while compiling with gcc:
~/test$ cat error2.scm; echo '-----'; gsc error2.scm; echo '-----'; gsc -link error2; gsi -e '(load "error2")' (c-declare #<<c-declare-end #include <stdio.h> void foo(const char* str) { fprintf(stderr, "printing: %s\n", str); } c-declare-end )
(define foo (c-lambda (char-string) void "foo"))
(foo "hello world")
error2.c:42: warning: deprecated conversion from string constant to ?char*? error2.c:42: warning: deprecated conversion from string constant to ?char*? error2.c:42: warning: deprecated conversion from string constant to ?char*? error2.c:174: warning: deprecated conversion from string constant to ?char*?
printing: hello world
I don't want to tell gcc to ignore this error. I want to get gambit to generate correct code. How do I do that?
(2) This is shown right in section 3.4.2 of the gambit reference manual:
$ gsc -link -flat -o foo.o1.c m2 m3 m2: m3: *** WARNING -- "cons" is not defined, *** referenced in: ("m2.c") *** WARNING -- "map" is not defined, *** referenced in: ("m3.c") *** WARNING -- "newline" is not defined, *** referenced in: ("m3.c") *** WARNING -- "write" is not defined, *** referenced in: ("m3.c")
Is there something I can put in m2.scm / m3.scm like "don't worry about cons / map / newline / write" ?
; File: "m2.scm" (c-declare "extern int power_of_2 ();") (define pow2 (c-lambda (int) int "power_of_2")) (define (twice x) (cons x x)) ; File: "m3.scm" (write (map twice (map pow2 '(1 2 3 4)))) (newline)
aside: I realize these are just small warnings. However, I'm doing alot of C-FFi library wrapping, and it's getting to be more than one screenful of warnings. This is bad as (1) I like things to be clean and (2) it makes it hard to view actual errors since there are so many silly warnings.
Thanks!