Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/cgo: "inconsistent definitions for C.CString" errors #17723
Something severely funky is happening with cgo as I try to create bindings for the X Windows library.
I know there is a bug relating to struct definitions where you get "inconsistent definitions", but this is a conflict for an object in the default C package which I am certainly not defining (and that text does not appear in the cgo include headers, nor does it appear as a symbol in the target library!)
What is really quite strange about this, is that it will randomly appear and disappear as I add functions to the library - it seems to be pretty dependent on some state which we might call "random" (possibly position of defs in the cgo generated sources?), but is reproducible on a single codebase state. I cannot seem to create a MCVE because of this, but I have uploaded the source of the project so far to https://github.com/dtromb/x11-cgo-bug - attempting to compile this should reproduce the issue.
I have really no idea how to debug this. First, I grepped through the generated cgo source, expecting to find a duplicate definition of
As you can see, there is a
This is something of a clue, as Xlib does define an
, so it is at least /plausible/ that something somewhere is mistaking this for the actual return type of
What version of Go are you using (
@ainar-g - That "one file" behavior seems to make some sense as it appears the parser caches types per file. Thanks for the workaround! I'm leaning toward wanting to investigate this further, as my previous random workaround worked at first, then stopped working! That will be good to let me continue along, at any rate...
The problem occurs when two files refer to
Testing a fix now.
Might it be good, in addition, to do some more tailored comparison of Name in cmd/cgo/main.go than