From b94f341baccebd574fbf3dd23445d0dfc9bf73d9 Mon Sep 17 00:00:00 2001 From: "Devon H. O'Dell" Date: Fri, 21 May 2010 17:31:18 -0700 Subject: [PATCH] cgo: better error for no C symbols R=rsc, iant CC=golang-dev, graeme.perrow https://golang.org/cl/1193046 --- src/cmd/cgo/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go index 070146c9acb..ac82ae91841 100644 --- a/src/cmd/cgo/main.go +++ b/src/cmd/cgo/main.go @@ -83,6 +83,11 @@ func main() { // Reset p.Preamble so that we don't end up with conflicting headers / defines p.Preamble = builtinProlog openProg(input, p) + + if len(p.Vardef) == 0 && len(p.Funcdef) == 0 && len(p.Enumdef) == 0 && len(p.Constdef) == 0 { + fatal("no C symbols were used in cgo file " + input) + } + for _, cref := range p.Crefs { // Convert C.ulong to C.unsigned long, etc. if expand, ok := expandName[cref.Name]; ok {