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: could not determine kind of name for C.datspecialnumber #9733

Closed
ghost opened this Issue Jan 29, 2015 · 7 comments

Comments

Projects
None yet
7 participants
@ghost

ghost commented Jan 29, 2015

Code in Go file:

package main

/*
#include <stdio.h>
int datspecialnumber() {
    return 2015;
}
*/

import "C"
import "fmt"

func main() {
    fmt.Println(C.datspecialnumber())
}

Output from go run test.go:

# command-line-arguments
could not determine kind of name for C.datspecialnumber

More info

go version go1.4 linux/amd64

gcc (GCC) 4.9.2 20141224 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/president/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

Anyone have an idea of what is causing this error? Am i doing something wrong?

@alicebob

This comment has been minimized.

Show comment
Hide comment
@alicebob

alicebob Jan 29, 2015

Remove the blank line above the import "C" line.

alicebob commented Jan 29, 2015

Remove the blank line above the import "C" line.

@davecheney

This comment has been minimized.

Show comment
Hide comment
@davecheney

davecheney Jan 30, 2015

Contributor

As @alicebob said, there should be no newline between the /* ... */ cgo block and import "C"

http://golang.org/cmd/cgo/

Contributor

davecheney commented Jan 30, 2015

As @alicebob said, there should be no newline between the /* ... */ cgo block and import "C"

http://golang.org/cmd/cgo/

@davecheney davecheney closed this Jan 30, 2015

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jan 30, 2015

Oops, my bad. Thanks for clearing that up, guys.

ghost commented Jan 30, 2015

Oops, my bad. Thanks for clearing that up, guys.

@mikioh mikioh changed the title from could not determine kind of name for C.datspecialnumber to cmd/cgo: could not determine kind of name for C.datspecialnumber Jan 30, 2015

@leomq

This comment has been minimized.

Show comment
Hide comment
@leomq

leomq Aug 24, 2015

Wow! I met the same problem.

leomq commented Aug 24, 2015

Wow! I met the same problem.

@ezwiebel

This comment has been minimized.

Show comment
Hide comment
@ezwiebel

ezwiebel Aug 1, 2016

The f**k! Thanks guys, was stuck for hours, it was driving me mad...
I love conventions but sometimes it's kind of harsh!

ezwiebel commented Aug 1, 2016

The f**k! Thanks guys, was stuck for hours, it was driving me mad...
I love conventions but sometimes it's kind of harsh!

@stgleb

This comment has been minimized.

Show comment
Hide comment
@stgleb

stgleb Aug 31, 2016

Contributor

I just want to add that multiline imports like

import (
               "C"
                "fmt"
)

Also breaks this stuff

Contributor

stgleb commented Aug 31, 2016

I just want to add that multiline imports like

import (
               "C"
                "fmt"
)

Also breaks this stuff

justinclift added a commit to justinclift/gosqlite that referenced this issue Apr 27, 2017

First attempt...
Not working though.  Compiling with Golang 1.8.1 says:

  $ go install .
  # github.com/justinclift/gosqlite
  could not determine kind of name for C.sqlite3_expanded_sql

Which makes no sense (to me).  Looking online shows this:

  golang/go#9733

Which seems like it should be relevant... but doesn't seem to be
the problem here (?)
@xgz123

This comment has been minimized.

Show comment
Hide comment
@xgz123

xgz123 May 18, 2017

Yeah the space might be the problem. But I still get this error when I'm trying to declare a c struct in cgo with no space between comments and import "C"

type record C.some_struct

// could not determine kind of name for C.some_struct

this time it really can not determine

xgz123 commented May 18, 2017

Yeah the space might be the problem. But I still get this error when I'm trying to declare a c struct in cgo with no space between comments and import "C"

type record C.some_struct

// could not determine kind of name for C.some_struct

this time it really can not determine

@golang golang locked and limited conversation to collaborators May 18, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.