having a problem using strings. Swig doesn't seem to be generating proper
interface code. Here's my test case:
*st.i
*%module st
%{
#include <string>
extern void pinput(const std::string& pstring);
%}
%include <std_string.i>
#include <string>
void pinput(const std::string& pstring);
*
st.cxx
*#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
void pinput(const std::string& pstring) {
std::cout<<pstring;
}
*
stmain.go
*package main
import (
"st"
)
func main() {
st.Pinput("This is a test.")
}
*
Makefile
*SWIG=/usr/bin/swig
SWIGOBJS = st_gc.c st_wrap.cxx st.go
all: st.so st.a
$(SWIGOBJS): st.i
$(SWIG) -go -c++ -intgosize 64 st.i
st.o: st.cxx
g++ -c -fpic -g -o st.o st.cxx
st_wrap.o: st_wrap.cxx
g++ -c -fpic -g -o st_wrap.o st_wrap.cxx
st.so: st_wrap.o st.o
g++ -shared st_wrap.o st.o -o st.so
st_gc.6: st_gc.c
go tool 6c -I `go env GOROOT`/pkg/`go env GOOS`_`go env GOARCH` st_gc.c
st.6: st.go
go tool 6g st.go
st.a: st.6 st_gc.6
go tool pack grc st.a st.6 st_gc.6
test: stmain
stmain: stmain.6
go tool 6l -L . -r . -o stmain stmain.6
stmain.6: stmain.go
go tool 6g -I . stmain.go
*
gdb output
*[[email protected] swigtest]$ gdb stmain
GNU gdb (GDB) Fedora (7.6-30.fc19)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/dave/go/src/swigtest/stmain...done.
warning: File "/usr/share/golang/src/pkg/runtime/runtime-gdb.py"
auto-loading ha
s been declined by your `auto-load safe-path' set to
"$debugdir:$datadir/auto-lo
ad:/usr/bin/mono-gdb.py".
To enable execution of this file add
add-auto-load-safe-path /usr/share/golang/src/pkg/runtime/runtime-gdb.py
line to your configuration file "/home/dave/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/home/dave/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the
shell:
info "(gdb)Auto-loading safe path"
(gdb) break st.Pinput
Breakpoint 1 at 0x419b20: file /home/dave/go/src/swigtest/st.go, line 36.
(gdb) run
Starting program: /home/dave/go/src/swigtest/stmain
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffe7d5d700 (LWP 7772)]
Breakpoint 1, st.Pinput (arg1=...) at /home/dave/go/src/swigtest/st.go:36
36 func Pinput(arg1 string) {
(gdb) p arg1
$1 = 0x42e8b0 "This is a test."
(gdb) step
37 _swig_wrap_pinput(arg1)
(gdb) p arg1
$2 = 0x42e8b0 "This is a test."
(gdb) step
st._swig_wrap_pinput (p=void) at /home/dave/go/src/swigtest/st_gc.c:28
28 ·_swig_wrap_pinput(struct {
(gdb) p p
$3 = void
(gdb)
*
*
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.