I was just running into the same issue:
does "g++ -Wno-write-strings ... your other options ..." get rid of the 'string constant -> char* deprecated' warning?
Hi,
I'm trying to get a toy, loadable C++ library compiled. My setup is as follows:
foo.scm:
(define bar (c-lambda (char-string) int "cpp_bar"))
foo.cpp:
int cpp_bar(char* text) {
return 0;
}
foo.h:
int cpp_bar(char* text);
I'm using the latest tarball of gambit, compiled with --enable-cplusplus.
I compile foo.scm to C++ via:
gsc -link -flat foo.scm ==> foo.c and foo_.c
Then I want to compile these into object files and I run into trouble. g++ -fPIC -c foo.c outputs the following:
oo.c: In function ‘int ___H__20_foo_23_0(___processor_state_struct*)’:
foo.c:119: error: ‘cpp_bar’ was not declared in this scope
foo.c: At global scope:
foo.c:156: warning: deprecated conversion from string constant to ‘char*’
Whereas gcc compiles it fine. It must be a name-mangling issue, but it seems peculiar to me, given that I compiled gsc using g++. Moreover, I can compile if I add extern "C" {int cpp_bar(char*);} to foo.c. I picked this up from reading about someone who had similar problems a few years ago:
http://osdir.com/ml/lisp.scheme.gambit/2005-02/msg00037.html
I then compile and link like:
g++ -fPIC -c -D___DYNAMIC foo_.c foo.c
g++ -fPIC -c -D___DYNAMIC foo.cpp -o cppfoo.o
ld -G -o foo.o1 /usr/lib/libstdc++.so.6.0.9 /usr/lib/gcc/i486-linux-gnu/4.2/crtbegin.o cppfoo.o foo_.o foo.o
Unfortunately, this leads me here:
*** WARNING -- Could not find C function: "____20_foo_2e_o1"
*** ERROR IN ##main -- .../foo.o1: undefined symbol: cpp_bar
(load "foo.o1")
Can anyone offer me any pointers on how to proceed?
-John
_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list