gotype and cgo, "invalid composite literal type"

1,073 views
Skip to first unread message

Nathan Youngman

unread,
Nov 27, 2014, 12:26:51 AM11/27/14
to golan...@googlegroups.com
Hi,

This is a case of code that builds and runs fine but gotype doesn't particularly care for:

context := C.FSEventStreamContext{info: unsafe.Pointer(es)}

$ gotype fsevents.go 
fsevents.go:208:13: invalid composite literal type invalid type

I saw one related issue about supporting cgo in cmd/vet.
https://code.google.com/p/go/issues/detail?id=4889

Personally, I'm not looking for that. I just would like to not have the error.

As cmd/stringer uses gotype under the hood, I also get this error there. The obvious workaround is to put the constants in a separate file that doesn't contain any C structs.

Nathan.

Robert Griesemer

unread,
Nov 29, 2014, 3:07:42 PM11/29/14
to Nathan Youngman, golan...@googlegroups.com
Please file a bug with the issue tracker with a minimal reproducible case and assign it to me. Thanks.
- gri

PS: The issue is that gotype doesn't know about cgo and types imported via "C". It tries to ignore respective errors as much as possible but it doesn't do a perfect job in some cases.

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nathan Youngman

unread,
Nov 30, 2014, 12:09:18 PM11/30/14
to Robert Griesemer, golang-dev
Hi Robert,

Thanks for looking into this. I don't see a way to assign the issue, but here is the link to it:


Thanks, Nathan.

--
Nathan Youngman 
Email: he...@nathany.com
Web: http://www.nathany.com
Reply all
Reply to author
Forward
0 new messages