{"action":"closed","issue":{"url":"https://api.github.com/repos/golang/go/issues/17723","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/17723/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/17723/comments","events_url":"https://api.github.com/repos/golang/go/issues/17723/events","html_url":"https://github.com/golang/go/issues/17723","id":186599900,"number":17723,"title":"cmd/cgo:  \"inconsistent definitions for C.CString\" errors","user":{"login":"dtromb","id":4296744,"avatar_url":"https://avatars.githubusercontent.com/u/4296744?v=3","gravatar_id":"","url":"https://api.github.com/users/dtromb","html_url":"https://github.com/dtromb","followers_url":"https://api.github.com/users/dtromb/followers","following_url":"https://api.github.com/users/dtromb/following{/other_user}","gists_url":"https://api.github.com/users/dtromb/gists{/gist_id}","starred_url":"https://api.github.com/users/dtromb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtromb/subscriptions","organizations_url":"https://api.github.com/users/dtromb/orgs","repos_url":"https://api.github.com/users/dtromb/repos","events_url":"https://api.github.com/users/dtromb/events{/privacy}","received_events_url":"https://api.github.com/users/dtromb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/38","html_url":"https://github.com/golang/go/milestones/Go1.8","labels_url":"https://api.github.com/repos/golang/go/milestones/38/labels","id":1709363,"number":38,"title":"Go1.8","description":"","creator":{"login":"griesemer","id":8528975,"avatar_url":"https://avatars.githubusercontent.com/u/8528975?v=3","gravatar_id":"","url":"https://api.github.com/users/griesemer","html_url":"https://github.com/griesemer","followers_url":"https://api.github.com/users/griesemer/followers","following_url":"https://api.github.com/users/griesemer/following{/other_user}","gists_url":"https://api.github.com/users/griesemer/gists{/gist_id}","starred_url":"https://api.github.com/users/griesemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/griesemer/subscriptions","organizations_url":"https://api.github.com/users/griesemer/orgs","repos_url":"https://api.github.com/users/griesemer/repos","events_url":"https://api.github.com/users/griesemer/events{/privacy}","received_events_url":"https://api.github.com/users/griesemer/received_events","type":"User","site_admin":false},"open_issues":175,"closed_issues":521,"state":"open","created_at":"2016-04-15T16:30:23Z","updated_at":"2016-11-01T23:06:43Z","due_on":"2017-01-31T00:00:00Z","closed_at":null},"comments":5,"created_at":"2016-11-01T17:49:41Z","updated_at":"2016-11-01T23:06:43Z","closed_at":"2016-11-01T23:06:43Z","body":"Something severely funky is happening with cgo as I try to create bindings for the X Windows library.\r\n\r\nI 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!)\r\n\r\nWhat 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.\r\n\r\nI have really no idea how to debug this.   First, I grepped through the generated cgo source, expecting to find a duplicate definition of `CString()` (or rather the C-mangled-name function implementing it).   I did not - there was only one.   I then noticed that the error is emitted from the cgo binary after a `reflect.DeepEqual()` comparison of the conflicting `*main.Name` types.   I tried rewriting `DeepEqual()` to provide some debugging information - and that was not helpful (package access rules thwarted the implementation).   Next, I wrote a function to dump the `Name` structure to a string, and all of the `ast.Expr` and friends so that we can see the exact differences.   I've attached those dumps as files here.\r\n\r\n[fail.txt](https://github.com/golang/go/files/564617/fail.txt)\r\n\r\n[fail2.txt](https://github.com/golang/go/files/564619/fail2.txt)\r\n\r\nAs you can see, there is a `Typedef` field in the `FuncType` record being set to \"XPointer\"; this corresponds, I believe, to the return type of the `CString()` implementation.\r\n\r\nThis is something of a clue, as Xlib does define an `XPointer` type, as follows:\r\n\r\n       Xlib.h:typedef char *XPointer;\r\n\r\n, so it is at least /plausible/ that something somewhere is mistaking this for the actual return type of `CString()`.  I'm sorry to say my trail ended here though, as I really don't know enough about the Go parser or these specific structures to progress easily further...\r\n\r\n\r\n### What version of Go are you using (`go version`)?\r\ngo version go1.7.3 linux/amd64\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\nGOARCH=\"amd64\"\r\nGOBIN=\"\"\r\nGOEXE=\"\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"linux\"\r\nGOOS=\"linux\"\r\nGOPATH=\"/home/dtrombley/go/path\"\r\nGORACE=\"\"\r\nGOROOT=\"/home/dtrombley/go/root\"\r\nGOTOOLDIR=\"/home/dtrombley/go/root/pkg/tool/linux_amd64\"\r\nCC=\"gcc\"\r\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build434390939=/tmp/go-build -gno-record-gcc-switches\"\r\nCXX=\"g++\"\r\nCGO_ENABLED=\"1\"\r\n\r\n\r\n### What did you do?\r\nI am attempting to compile a valid Go program with cgo interfaces to the X library.\r\n\r\n### What did you expect to see?\r\nCompleted Proper compilation.\r\n\r\n### What did you see instead?\r\ncgo emits: \"inconsistent definitions for C.CString\"\r\n\r\n\r\n"}}
{"actor":{"display_login":"gopherbot"}}