Re: [go-nuts] ask for you help about cgo and interface

2019-12-04 Thread Ian Lance Taylor
On Wed, Dec 4, 2019 at 5:21 PM FAN DEAR wrote: > > First of all, thank you very much for your reply. > Actually, what I want to do is to use golang to complete the TCP > communication SDK. > When C++ calls golang to send a message, > I need to tell the C++ message sending status at the appropriat

Re: [go-nuts] ask for you help about cgo and interface

2019-12-04 Thread FAN DEAR
First of all, thank you very much for your reply. Actually, what I want to do is to use golang to complete the TCP communication SDK. When C++ calls golang to send a message, I need to tell the C++ message sending status at the appropriate time, such as sending failed, sending successfully, and

Re: [go-nuts] ask for you help about cgo and interface

2019-12-03 Thread Ian Lance Taylor
On Tue, Dec 3, 2019 at 12:29 AM FAN DEAR wrote: > > typedef struct { void *t; void *v; } GoInterface; > > > What is *t and *v? See https://research.swtch.com/interfaces. Ian > 在 2019年12月3日星期二 UTC+8上午2:41:36,Ian Lance Taylor写道: >> >> On Mon, Dec 2, 2019 at 9:57 AM FAN DEAR wrote: >> > >> > >>

Re: [go-nuts] ask for you help about cgo and interface

2019-12-03 Thread FAN DEAR
typedef struct { void *t; void *v; } GoInterface; What is *t and *v? 在 2019年12月3日星期二 UTC+8上午2:41:36,Ian Lance Taylor写道: > > On Mon, Dec 2, 2019 at 9:57 AM FAN DEAR > > wrote: > > > > > > How to use add2 function, i am very troubled. > > On this mailing list please post code as ordinary tex

Re: [go-nuts] ask for you help about cgo and interface

2019-12-02 Thread Ian Lance Taylor
On Mon, Dec 2, 2019 at 9:57 AM FAN DEAR wrote: > > > How to use add2 function, i am very troubled. On this mailing list please post code as ordinary text, or as a link to the Go playground. Don't post colorized images with a black background. Thanks. You can't declare a Go interface type in C.

[go-nuts] ask for you help about cgo and interface

2019-12-02 Thread FAN DEAR
in my go file: package main import "C" // AddListener ... //export AddListener type AddListener interface { addResult(i int) } func main() { } // Add ... //export Add func Add(i, j int) int { return i + j } // Add2 ... //export Add2 func Add2(i, j int, listener AddListener) { listener.addResu