Skip to content

Commit

Permalink
cmd/cgo: clarify implicit "cgo" build constraint
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ikkerens authored Feb 23, 2018
1 parent 9ee78af commit 2a298db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cmd/cgo/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ it is expected to work. It is disabled by default when
cross-compiling. You can control this by setting the CGO_ENABLED
environment variable when running the go tool: set it to 1 to enable
the use of cgo, and to 0 to disable it. The go tool will set the
build constraint "cgo" if cgo is enabled.
build constraint "cgo" if cgo is enabled. When the Go tool sees the
special import "C", the "cgo" build constraint will be implied, causing
the tool to skip the file if CGO_ENABLED is set to 0.
When cross-compiling, you must specify a C cross-compiler for cgo to
use. You can do this by setting the generic CC_FOR_TARGET or the
Expand Down

0 comments on commit 2a298db

Please sign in to comment.