Home | History | Annotate | Download | only in cgo

Lines Matching refs:cgo

7 Cgo enables the creation of Go packages that call C code.
9 Using cgo with the go command
11 To use cgo write normal Go code that imports a pseudo-package "C".
30 See $GOROOT/misc/cgo/stdio and $GOROOT/misc/cgo/gmp for examples. See
31 "C? Go? Cgo!" for an introduction to using cgo:
34 CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS may be defined with pseudo #cgo
42 // #cgo CFLAGS: -DPNG_DEBUG=1
43 // #cgo amd64 386 CFLAGS: -DX86=1
44 // #cgo LDFLAGS: -lpng
49 tool using a '#cgo pkg-config:' directive followed by the package names.
52 // #cgo pkg-config: png cairo
62 All the cgo CPPFLAGS and CFLAGS directives in a package are concatenated and
70 When the cgo directives are parsed, any occurrence of the string ${SRCDIR}
76 // #cgo LDFLAGS: -L${SRCDIR}/libs -lfoo
80 // #cgo LDFLAGS: -L/go/src/foo/libs -lfoo
93 The cgo tool is enabled by default for native builds on systems where
97 the use of cgo, and to 0 to disable it. The go tool will set the
98 build constraint "cgo" if cgo is enabled.
100 When cross-compiling, you must specify a C cross-compiler for cgo to
131 Cgo translates C types into equivalent unexported Go types.
213 copied from the cgo input files. Functions with multiple
224 Using cgo directly
227 go tool cgo [cgo options] [-- compiler options] gofiles...
229 Cgo transforms the specified input Go source files into several output
235 The following options are available when running cgo directly:
240 build when building a cgo package.
268 If set (which it is by default) import runtime/cgo in
283 Cgo provides a way for Go programs to call C code linked into the same
284 address space. This comment explains the operation of cgo.
286 Cgo reads a set of Go source files and looks for statements saying
289 generated by cgo. A typical preamble #includes necessary definitions:
294 For more details about the usage of cgo, see the documentation
299 Cgo scans the Go source files that import "C" for uses of that
302 to a type, a function, a constant, or a global variable. Cgo must
305 The obvious thing for cgo to do is to process the preamble, expanding
313 Cgo takes a different approach. It determines the meaning of C
320 Cgo first invokes gcc -E -dM on the preamble, in order to find out
324 Next, cgo needs to identify the kinds for each identifier. For the
325 identifiers C.foo and C.bar, cgo generates this C program:
341 This program will not compile, but cgo can use the presence or absence
353 Next, cgo must learn the details of each type, variable, function, or
354 constant. It can do this by reading object files. If cgo has decided
380 containing debug information. Cgo parses the DWARF debug information
383 cgo can parse the DWARF debug information for the __cgo_enum__N to
385 incomplete DWARF information for enums; in that case cgo reads the
389 At this point cgo knows the meaning of each C.xxx well enough to start
398 Given the input Go files x.go and y.go, cgo generates these source
441 The hexadecimal number is a hash of cgo's input, chosen to be
485 cgo examine the executable. Cgo records the list of shared library
505 files generated from C files that cgo writes, and those are much more
517 package net uses cgo for access to name resolution functions provided
523 When using cgo, Go must not assume that it owns all details of the
534 Any package using cgo imports "runtime/cgo", which provides
552 dynamic libraries, cgo supports an "external" linking mode too. In
562 binary. When cgo is involved, the compile step already requires gcc, so
566 standard library. In particular, package net uses cgo on most systems,
575 circumstances: if net is the only cgo-using package, then internal
622 supplied by runtime/cgo.
666 A package compiled with cgo will include directives for both
672 As a simple example, consider a package that uses cgo to call C.sin.
673 The following code will be generated by cgo:
728 provided to the host linker by foo2.cgo.o, which in turn will need the
746 packages using cgo are those on a whitelist of standard library
747 packages (net, os/user, runtime/cgo), 6l will use internal linking
748 mode. Otherwise, there are non-standard cgo packages involved, and 6l
750 the godoc binary, which uses net but no other cgo, can run without
752 cgo-wrapped library like sqlite3 can generate a standalone executable