cl: _testcgo/typalias

This commit is contained in:
xushiwei
2024-04-27 08:33:49 +08:00
parent 00b2fd1479
commit 46a9df47e4
3 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
package main
import "C"
import _ "unsafe"
//go:linkname printf C.printf
func printf(format *int8, __llgo_va_list ...any)
type Foo = struct {
A C.int
ok bool
}
var format = [...]int8{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
func Print(p *Foo) {
if p.ok {
printf(&format[0], p.A)
}
}
func main() {
foo := &Foo{100, true}
Print(foo)
}

View File

View File

@@ -28,7 +28,7 @@ func testCompile(t *testing.T, src, expected string) {
}
func TestFromTestcgo(t *testing.T) {
cltest.FromDir(t, "", "./_testcgo", true)
cltest.FromDir(t, "typalias", "./_testcgo", true)
}
func TestFromTestdata(t *testing.T) {