Commit cbfda7f8 authored by Rens Rikkerink's avatar Rens Rikkerink Committed by Ian Lance Taylor

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.
Explicitly explain this in the documentation.

Updates #24068

Change-Id: Ib656ceccd52c749ffe7fb2d3db9ac144f17abb32
GitHub-Last-Rev: 5a13f00a9b917e51246a5fbb642c4e9ed55aa21d
GitHub-Pull-Request: golang/go#24072
Reviewed-on: https://go-review.googlesource.com/96655Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 515fa58a
...@@ -109,7 +109,11 @@ it is expected to work. It is disabled by default when ...@@ -109,7 +109,11 @@ it is expected to work. It is disabled by default when
cross-compiling. You can control this by setting the CGO_ENABLED cross-compiling. You can control this by setting the CGO_ENABLED
environment variable when running the go tool: set it to 1 to enable 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 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. The special import "C"
implies the "cgo" build constraint, as though the file also said
"// +build cgo". Therefore, if cgo is disabled, files that import
"C" will not be built by the go tool. (For more about build constraints
see https://golang.org/pkg/go/build/#hdr-Build_Constraints).
When cross-compiling, you must specify a C cross-compiler for cgo to 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 use. You can do this by setting the generic CC_FOR_TARGET or the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment