Skip to content

Commit 2a298db

Browse files
authored
cmd/cgo: clarify implicit "cgo" build constraint
When using the special import "C", the "cgo" build constraint is implied for the go file, potentially triggering unclear "undefined" error messages. The documentation so far did not yet mention this.
1 parent 9ee78af commit 2a298db

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cmd/cgo/doc.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ it is expected to work. It is disabled by default when
109109
cross-compiling. You can control this by setting the CGO_ENABLED
110110
environment variable when running the go tool: set it to 1 to enable
111111
the use of cgo, and to 0 to disable it. The go tool will set the
112-
build constraint "cgo" if cgo is enabled.
112+
build constraint "cgo" if cgo is enabled. When the Go tool sees the
113+
special import "C", the "cgo" build constraint will be implied, causing
114+
the tool to skip the file if CGO_ENABLED is set to 0.
113115
114116
When cross-compiling, you must specify a C cross-compiler for cgo to
115117
use. You can do this by setting the generic CC_FOR_TARGET or the

0 commit comments

Comments
 (0)