
This is a large refactor of the cgo package. It should fix a number of smaller problems and be a bit more strict (like upstream CGo): it for example requires every Go file in a package to include the header files it needs instead of piggybacking on imports in earlier files. The main benefit is that it should be a bit more maintainable and easier to add new features in the future (like static functions). This breaks the tinygo.org/x/bluetooth package, which should be updated before this change lands.
47 строки
1 КиБ
Go
47 строки
1 КиБ
Go
// CGo errors:
|
|
// testdata/flags.go:5:7: invalid #cgo line: NOFLAGS
|
|
// testdata/flags.go:8:13: invalid flag: -fdoes-not-exist
|
|
// testdata/flags.go:29:14: invalid flag: -does-not-exists
|
|
|
|
package main
|
|
|
|
import "unsafe"
|
|
|
|
var _ unsafe.Pointer
|
|
|
|
//go:linkname C.CString runtime.cgo_CString
|
|
func C.CString(string) *C.char
|
|
|
|
//go:linkname C.GoString runtime.cgo_GoString
|
|
func C.GoString(*C.char) string
|
|
|
|
//go:linkname C.__GoStringN runtime.cgo_GoStringN
|
|
func C.__GoStringN(*C.char, uintptr) string
|
|
|
|
func C.GoStringN(cstr *C.char, length C.int) string {
|
|
return C.__GoStringN(cstr, uintptr(length))
|
|
}
|
|
|
|
//go:linkname C.__GoBytes runtime.cgo_GoBytes
|
|
func C.__GoBytes(unsafe.Pointer, uintptr) []byte
|
|
|
|
func C.GoBytes(ptr unsafe.Pointer, length C.int) []byte {
|
|
return C.__GoBytes(ptr, uintptr(length))
|
|
}
|
|
|
|
type (
|
|
C.char uint8
|
|
C.schar int8
|
|
C.uchar uint8
|
|
C.short int16
|
|
C.ushort uint16
|
|
C.int int32
|
|
C.uint uint32
|
|
C.long int32
|
|
C.ulong uint32
|
|
C.longlong int64
|
|
C.ulonglong uint64
|
|
)
|
|
|
|
const C.BAR = 3
|
|
const C.FOO_H = 1
|