mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cgo: bug fixes
* Add documentation about array arguments. Fixes issue 1125. * Do not interpret x, y := z, w as special errno form. Fixes issue 952. * Fix nested Go calls (brainman). Fixes issue 907. R=r CC=golang-dev https://golang.org/cl/2214044
This commit is contained in:
parent
58795ea31a
commit
a2450c1456
4 changed files with 40 additions and 5 deletions
|
|
@ -27,6 +27,12 @@ C identifiers or field names that are keywords in Go can be
|
|||
accessed by prefixing them with an underscore: if x points at
|
||||
a C struct with a field named "type", x._type accesses the field.
|
||||
|
||||
The standard C numeric types are available under the names
|
||||
C.char, C.schar (signed char), C.uchar (unsigned char),
|
||||
C.short, C.ushort (unsigned short), C.int, C.uint (unsigned int),
|
||||
C.long, C.ulong (unsigned long), C.longlong (long long),
|
||||
C.ulonglong (unsigned long long), C.float, C.double.
|
||||
|
||||
To access a struct, union, or enum type directly, prefix it with
|
||||
struct_, union_, or enum_, as in C.struct_stat.
|
||||
|
||||
|
|
@ -36,6 +42,12 @@ C errno variable as an os.Error. For example:
|
|||
|
||||
n, err := C.atoi("abc")
|
||||
|
||||
In C, a function argument written as a fixed size array
|
||||
actually requires a pointer to the first element of the array.
|
||||
C compilers are aware of this calling convention and adjust
|
||||
the call accordingly, but Go cannot. In Go, you must pass
|
||||
the pointer to the first element explicitly: C.f(&x[0]).
|
||||
|
||||
Cgo transforms the input file into four output files: two Go source
|
||||
files, a C file for 6c (or 8c or 5c), and a C file for gcc.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue