Skip to content

Commit

Permalink
Merge pull request #389 from xushiwei/q
Browse files Browse the repository at this point in the history
cppintf: c++ name
  • Loading branch information
xushiwei authored Jun 22, 2024
2 parents 451e695 + b4fd4a0 commit 24d345a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions _demo/cppintf/cppintf.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ func (p *Bar) sqrt(v float64) float64 {
func main() {
bar := NewBar(1)
foo.F(&bar.Callback)
foo.G(&bar.Callback)
}
4 changes: 4 additions & 0 deletions _demo/cppintf/foo/bar/bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ interface ICallback {
extern "C" void f(ICallback* cb) {
printf("val: %d\ncalc(2): %lf\n", cb->val(), cb->calc(2));
}

void g(ICallback* cb) {
f(cb);
}
3 changes: 3 additions & 0 deletions _demo/cppintf/foo/foo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ type CallbackVtbl struct {

//go:linkname F C.f
func F(cb *Callback)

//go:linkname G C._Z1gP9ICallback
func G(cb *Callback)

0 comments on commit 24d345a

Please sign in to comment.