~/error$ cat comp.scm (c-declare #<<end typedef struct foo { int x, y; } foo;
foo global_foo;
//foo* get_foo(const char* s) foo* get_foo(int) { return &global_foo; }
foo* get_str_foo(const char* s) { return &global_foo; }
int add(int x) { return x + 2; }
end )
(c-define-type foo "foo") (c-define-type void* (pointer void)) (c-define-type foo* (pointer foo)) (define add (c-lambda (int) int "add")) (define get-foo (c-lambda (int) foo* "get_foo")); (define get-foo2 (c-lambda (int) void* "get_foo")); (define get-str-foo2 (c-lambda (char-string) void* "get_str_foo")); (define get-str-foo (c-lambda (char-string) foo* "get_str_foo"));
~/error$ cat make.scm #!/usr/local/Gambit-C/bin/gsc -i
(compile-file-to-c "comp") (link-flat '("comp") output: "comp.o1.c") (shell-command "g++ -shared -D___DYNAMIC -fPIC comp.c comp.o1.c -o comp.o1")
~/error$ cat int.scm (load "comp") (pp (add 2)) (pp (get-foo2 2)) (pp (get-foo 2)) (pp (get-str-foo2 "hello")) (pp (get-str-foo "world"))
Question: what's the difference between get-str-foo2 and get-foo2 that causes one to work and one throw an error?