Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: C struct embedding error #2552

Closed
gopherbot opened this issue Dec 11, 2011 · 7 comments
Closed

cmd/cgo: C struct embedding error #2552

gopherbot opened this issue Dec 11, 2011 · 7 comments
Milestone

Comments

@gopherbot
Copy link

by matteo.goggi:

1. What is a short input program that triggers the error?
--------------------------------
test.go
--------------------------------
package test

/*
typedef struct cStruct {
        double X;
} cStruct;

double cFunc(cStruct str) {
        return str.X * 100;
}
*/
import "C"

type GoStruct struct {
        C.cStruct
}

func (str GoStruct) GoFunc () float64 {
        return float64(C.cFunc(str.cStruct))
}
--------------------------------
Makefile
--------------------------------
include $(GOROOT)/src/Make.inc

TARG=test
CGOFILES=\
        test.go

include $(GOROOT)/src/Make.pkg
--------------------------------
2. What is the full compiler output?
CGOPKGPATH= cgo --  test.go
touch _obj/_cgo_run
6g   -p test -o _go_.6  _obj/test.cgo1.go _obj/_cgo_gotypes.go
test.go:8[_obj/test.cgo1.go:11]: str.cStruct undefined (type GoStruct has no field or
method cStruct)
make: *** [_go_.6] Error 1

3. What version of the compiler are you using?  (Run it with the -V flag.)

6g version weekly.2011-12-06 10712
@rsc
Copy link
Contributor

rsc commented Dec 12, 2011

Comment 1:

Labels changed: added priority-go1.

@remyoudompheng
Copy link
Contributor

Comment 2:

In Matteo's example, do we expect that str.X is a valid selector? That would be tricky
to implement.

@rsc
Copy link
Contributor

rsc commented Dec 19, 2011

Comment 3:

I think it would be fine to document that C types do not work
as embedded fields.
Russ

@robpike
Copy link
Contributor

robpike commented Jan 13, 2012

Comment 4:

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Jan 13, 2012

Comment 5:

Owner changed to builder@golang.org.

@rsc
Copy link
Contributor

rsc commented Feb 17, 2012

Comment 7:

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Feb 19, 2012

Comment 8:

This issue was closed by revision 1a0c8fe.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants