annotate libgo/misc/cgo/test/issue8148.go @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Copyright 2014 The Go Authors. All rights reserved.
kono
parents:
diff changeset
2 // Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
3 // license that can be found in the LICENSE file.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 // Issue 8148. A typedef of an unnamed struct didn't work when used
kono
parents:
diff changeset
6 // with an exported Go function. No runtime test; just make sure it
kono
parents:
diff changeset
7 // compiles.
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 package cgotest
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 /*
kono
parents:
diff changeset
12 typedef struct { int i; } T;
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 int issue8148Callback(T*);
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 static int get() {
kono
parents:
diff changeset
17 T t;
kono
parents:
diff changeset
18 t.i = 42;
kono
parents:
diff changeset
19 return issue8148Callback(&t);
kono
parents:
diff changeset
20 }
kono
parents:
diff changeset
21 */
kono
parents:
diff changeset
22 import "C"
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 //export issue8148Callback
kono
parents:
diff changeset
25 func issue8148Callback(t *C.T) C.int {
kono
parents:
diff changeset
26 return t.i
kono
parents:
diff changeset
27 }
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 func Issue8148() int {
kono
parents:
diff changeset
30 return int(C.get())
kono
parents:
diff changeset
31 }