From 9f3a2d5f9abb148c4e543a3e7046b46d0bb9cc07 Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Thu, 18 Jun 2015 21:43:01 +0200 Subject: [PATCH] doc: clarify duplicate symbol condition in cgo Spell out what will happen if a declaration and definition is included in the same file, should help people who run into duplicate symbol errors and search for relevant keywords. This edit is based on opening issue #11263 erroneously. Change-Id: I0645a9433b8668d2ede9b9a3f6550d802c26388b Reviewed-on: https://go-review.googlesource.com/11247 Reviewed-by: Ian Lance Taylor --- src/cmd/cgo/doc.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/cgo/doc.go b/src/cmd/cgo/doc.go index 1a2595b766..9630460391 100644 --- a/src/cmd/cgo/doc.go +++ b/src/cmd/cgo/doc.go @@ -207,8 +207,10 @@ Not all Go types can be mapped to C types in a useful way. Using //export in a file places a restriction on the preamble: since it is copied into two different C output files, it must not -contain any definitions, only declarations. Definitions must be -placed in preambles in other files, or in C source files. +contain any definitions, only declarations. If a file contains both +definitions and declarations, then the two output files will produce +duplicate symbols and the linker will fail. To avoid this, definitions +must be placed in preambles in other files, or in C source files. Using cgo directly -- 2.48.1