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: When building cgo, I get an error 'could not determine kind of name for var' #23819

Closed
derktam opened this issue Feb 14, 2018 · 2 comments

Comments

@derktam
Copy link

commented Feb 14, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.4 freebsd/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOOS="freebsd"
GOPATH="/root/work"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

main.go ( https://play.golang.org/p/HrkbEQRd670 )

package main
  
/*
int test1() {

}
struct test2 {
        unsigned int ncpus;
        int epoch_number;
        int netmap_extra_bufs;
};

 */
import "C"

func main() {
        C.test1()
        var test C.test2
        _ = test
}

result:

go run main.go
./main.go:18:11: could not determine kind of name for C.test2

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

I want to build and run it correctly.

What did you see instead?

go run main.go
./main.go:18:11: could not determine kind of name for C.test2
@AlexRouSg

This comment has been minimized.

Copy link
Contributor

commented Feb 14, 2018

https://golang.org/cmd/cgo/

To access a struct, union, or enum type directly, prefix it with struct_, union_, or enum_, as in C.struct_stat.

The type is named C.struct_test2

@derktam

This comment has been minimized.

Copy link
Author

commented Feb 14, 2018

It is my mistake. Thank you.

@derktam derktam closed this Feb 14, 2018

@mikioh mikioh changed the title When building cgo, I get an error 'could not determine kind of name for var' cmd/cgo: When building cgo, I get an error 'could not determine kind of name for var' Feb 21, 2018

@golang golang locked and limited conversation to collaborators Feb 21, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.