From 1a040c923035fbab613ef9f37422e91ac01ff911 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 17 Jun 2015 18:03:16 -0700 Subject: [PATCH] cmd/cgo: static variables in the preamble may not be referenced This is a documentation fix that reflects the current reality. Fixes #9673. Change-Id: Ie436b277dfd1b68b13c67813d29c238d2c23b820 Reviewed-on: https://go-review.googlesource.com/11221 Reviewed-by: Russ Cox --- src/cmd/cgo/doc.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/cgo/doc.go b/src/cmd/cgo/doc.go index 9630460391..6ac0381f5a 100644 --- a/src/cmd/cgo/doc.go +++ b/src/cmd/cgo/doc.go @@ -20,6 +20,13 @@ the C parts of the package. For example: // #include import "C" +The preamble may contain any C code, including function and variable +declarations and definitions. These may then be referred to from Go +code as though they were defined in the package "C". All names +declared in the preamble may be used, even if they start with a +lower-case letter. Exception: static variables in the preamble may +not be referenced from Go code; static functions are permitted. + See $GOROOT/misc/cgo/stdio and $GOROOT/misc/cgo/gmp for examples. See "C? Go? Cgo!" for an introduction to using cgo: http://golang.org/doc/articles/c_go_cgo.html. -- 2.50.0