Is the following code supposed to work? Not sure whether I'm doing something wrong or cgo just doesn't support this style of #defines. I reduced it down to a simple test case, but the actual problem I ran into came from some 3rd party .h files that unfortunately I have no control over.
package main /* #include <stdio.h> #define VERSION_A "1.2.3" *#define VERSION_B VERSION_A* void f() { printf("VERSION_A: %s, VERSION_B: %s\n", VERSION_A, VERSION_B); } */ import "C" import "fmt" func main() { C.f() fmt.Println("VERSION_A:", C.VERSION_A) // This does not compile fmt.Println("VERSION_B:", C.VERSION_B) } The error I get: % go run cgodefine.go # command-line-arguments /tmp/go-build088092139/command-line-arguments/_obj/_cgo_main.o:(.data.rel+0x0): undefined reference to `VERSION_A' collect2: error: ld returned 1 exit status If I run: % go tool cgo -godefs cgodefine.go I end up with: // Created by cgo -godefs - DO NOT EDIT // cgo -godefs cgodefine.go package main import "fmt" func main() { _Cfunc_f() fmt.Println("VERSION_A:", "1.2.3") *fmt.Println("VERSION_B:", *_Cvar_VERSION_B)* } Thank you for your help. Dragos -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.