Skip to content

Commit 71ed6eb

Browse files
committed
misc/cgo/test: test of issue 4339
This is not quite what that issue reports, because this does not involve a DLL. But I wanted to make sure this much was working. Update #4339 R=golang-dev, minux.ma CC=golang-dev https://golang.org/cl/13653043
1 parent 3ee0744 commit 71ed6eb

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

misc/cgo/test/cgo_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ func Test5603(t *testing.T) { test5603(t) }
4545
func Test3250(t *testing.T) { test3250(t) }
4646
func TestCallbackStack(t *testing.T) { testCallbackStack(t) }
4747
func TestFpVar(t *testing.T) { testFpVar(t) }
48+
func Test4339(t *testing.T) { test4339(t) }
4849

4950
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }

misc/cgo/test/issue4339.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
#include "issue4339.h"
3+
4+
static void
5+
impl(void)
6+
{
7+
//printf("impl\n");
8+
}
9+
10+
Issue4339 exported4339 = {"bar", impl};
11+
12+
void
13+
handle4339(Issue4339 *x)
14+
{
15+
//printf("handle\n");
16+
x->bar();
17+
//printf("done\n");
18+
}

misc/cgo/test/issue4339.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2013 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package cgotest
6+
7+
/*
8+
#include "issue4339.h"
9+
*/
10+
import "C"
11+
12+
import "testing"
13+
14+
func test4339(t *testing.T) {
15+
C.handle4339(&C.exported4339)
16+
}

misc/cgo/test/issue4339.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
typedef struct Issue4339 Issue4339;
2+
3+
struct Issue4339 {
4+
char *name;
5+
void (*bar)(void);
6+
};
7+
8+
extern Issue4339 exported4339;
9+
void handle4339(Issue4339*);

0 commit comments

Comments
 (0)