]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: document workaround for C struct_stat function
authorIan Lance Taylor <iant@golang.org>
Wed, 31 Jul 2024 20:16:23 +0000 (13:16 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 31 Jul 2024 23:17:05 +0000 (23:17 +0000)
For #68682

Change-Id: I13b61f915925a9ee510e0a42e95da7a83678b3b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/602215
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/cgo/doc.go

index 3d4789fafb77eca87158ae25147aea77646be095..8e11a12740724460fb6378cda57ab8ed6ffe31e6 100644 (file)
@@ -163,10 +163,14 @@ type in Go are instead represented by a uintptr.  See the Special
 cases section below.
 
 To access a struct, union, or enum type directly, prefix it with
-struct_, union_, or enum_, as in C.struct_stat.
-
-The size of any C type T is available as C.sizeof_T, as in
-C.sizeof_struct_stat.
+struct_, union_, or enum_, as in C.struct_stat. The size of any C type
+T is available as C.sizeof_T, as in C.sizeof_struct_stat. These
+special prefixes means that there is no way to directly reference a C
+identifier that starts with "struct_", "union_", "enum_", or
+"sizeof_", such as a function named "struct_function".
+A workaround is to use a "#define" in the preamble, as in
+"#define c_struct_function struct_function" and then in the
+Go code refer to "C.c_struct_function".
 
 A C function may be declared in the Go file with a parameter type of
 the special name _GoString_. This function may be called with an