assume there is a c++ function   string getpath()

 you mean I should do this ?

>  


char *CGetPath() {
> auto str=getpath; 
> char *c = malloc(str.length()), 
> strcpy(c,str.c_str()); 
> return c;
> }

    

  p :=C.CGetPath()  
>       gostr := C.GoString() 
>    C.free(p)




在 2017年4月18日星期二 UTC+8下午6:44:59,Konstantin Khomoutov写道:
>
> On Tue, 18 Apr 2017 02:25:07 -0700 (PDT) 
> hui zhang <fastf...@gmail.com <javascript:>> wrote: 
>
> > c code 
> > string getstring() {...} 
> > 
> > go 
> > 
> > string gostr = ????(C.getstring()) 
>
> Oh, and note that std::string is a fat object. 
>
> So if getstring() really returns an instance of std::string, 
> and you need to actually extract its "raw bytes", you'd need to call 
> the c_str() method of std::string on that object before applying the 
> techniques from [1] to it. 
>
> 1. https://github.com/golang/go/wiki/cgo#go-strings-and-c-strings 
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to