cgo:build trouble

114 views
Skip to first unread message

liaoy...@gmail.com

unread,
Mar 18, 2019, 12:36:50 AM3/18/19
to golang-nuts
package main

import(
)

/*
#include <stdio.h>
*/
import "C"

func main() {
C.printf(C.CString("hello"))
}

//---->build this file with go build, i got
//./testems.go:12:2: unexpected type: ...

could someone help me with this trouble? thanks!


Ian Lance Taylor

unread,
Mar 18, 2019, 11:25:54 PM3/18/19
to liaoy...@gmail.com, golang-nuts
Calling variadic C functions like printf is not supported. See the
docs (https://golang.org/cmd/cgo) for a workaround.

I admit the error message is not the best. Feel free to open an issue
to improve it, at https://golang.org/issue. Thanks.

Ian
Reply all
Reply to author
Forward
0 new messages