Linking C libraries with go-lang and "-std=c99"

I have been playing around with Google's new Go language ("golang" or "go-lang" if you are trying to Google for it!), and have been most intrigued about its ability to call C libraries.

Unfortunately, I found it very difficult to get up and running with this.  The c code I was attempting to integrate with uses the "-std=c99" flag.  Therefore, my Go file looked like:

package main
import "fmt"

// #cgo CFLAGS: -std=std99 -msse4.1 -I../c/core/
// #cgo LDFLAGS: -L. -lgotest
// #include "go-test.h"
import "C"
func main() { 
   cs := int(C.quick_test())
   fmt.Println("Hello, ", cs )

Which when compiled would give the following output:


 go build tester.go
# command-line-arguments
tester.go:7:1: error: return type defaults to 'int' [-Werror]
tester.go: In function 'typeof':
tester.go:7:20: error: expected declaration specifiers before '*' token
tester.go:8:1: error: parameter '__cgodebug_data' is initialized
tester.go:11:1: error: excess elements in scalar initializer [-Werror]
tester.go:11:1: error: (near initialization for '__cgodebug_data') [-Werror]
tester.go:7:1: error: type of 'quick_test' defaults to 'int' [-Werror]
tester.go:8:11: error: declaration for parameter '__cgodebug_data' but no such parameter
tester.go:11:1: error: expected '{' at end of input
tester.go:11:1: error: control reaches end of non-void function [-Werror=return-type]
cc1: all warnings being treated as errors


Which is to say, nothing useful at all (although hopefully Google will find this, and someone searching for the errors will find this and not have to waste an afternoon debugging)!

Removing the "-std=std99" or replacing it with "-std=gnu99" will make everything work properly again.