I'm wrapping a large, complex library with a Go language binding. At some point, I started getting the following strange error when I ran go build
:
inconsistent definitions for C.CString
I do not, and the library does not define/redefine CString in any way.
I find I'm unable to make a MCVE demonstrating the problem (the code is thousands of lines), but I do have it down to happening/not-happening depending on the presence of a single line:
d := C.FunctionDefinedInLibHeader
Of course, if I try to reference this in a minimal example, it works fine.
My question is: How can I attempt to debug this error? I tried using
go tool cgo
to generate the C sources, and nothing looked out of the ordinary (in particular CString
is only ever called, not defined), and the sources compiled fine. I just don't understand where that error message is coming from (it's not the C compiler, in particular), or what it even means. But when the C function is referenced in the code, it appears, and when it is not, the problem disappears.
I know there is an old Go bug which produces a similar error, but in that case the duplicated definition is a library-defined symbol, not a basic cgo internal function.