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: 'a' and 'r' cannot be used as C function name #23356

Closed
hirochachacha opened this issue Jan 6, 2018 · 3 comments
Closed

cmd/cgo: 'a' and 'r' cannot be used as C function name #23356

hirochachacha opened this issue Jan 6, 2018 · 3 comments
Milestone

Comments

@hirochachacha
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What did you do?

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

package main

// int a(void) { return 5; };
import "C"
import "fmt"

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

What did you expect to see?

5

What did you see instead?

# command-line-arguments
cgo-gcc-prolog:40:7: error: called object type 'struct (anonymous struct at cgo-gcc-prolog:33:2) *' is not a function or function pointer

Does this issue reproduce with the latest release (go1.9.2)?

yes

System details

go version devel +3aeb3950a9 Mon Dec 18 20:24:12 2017 +0000 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hiro/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hiro/.go"
GORACE=""
GOROOT="/Users/hiro/go"
GOTMPDIR=""
GOTOOLDIR="/Users/hiro/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build977751088=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version devel +3aeb3950a9 Mon Dec 18 20:24:12 2017 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel +3aeb3950a9 Mon Dec 18 20:24:12 2017 +0000
uname -v: Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.13.2
BuildVersion:	17C88
lldb --version: lldb-900.0.64
  Swift-4.0
gdb --version: GNU gdb (GDB) 8.0.1
@gopherbot
Copy link

Change https://golang.org/cl/86495 mentions this issue: cmd/cgo: avoid name confliction for C functions

@odeke-em
Copy link
Member

odeke-em commented Jan 7, 2018

@hirochachacha is this a regression from any of the previous Go releases? If so, please change the milestone, otherwise I'll mark it for Go1.11.

@odeke-em odeke-em added this to the Go1.11 milestone Jan 7, 2018
@hirochachacha
Copy link
Contributor Author

The issue itself is there since day one.
However we change the macro algorithm at Go1.10. I hit on some combinations.

package main

// int a = 5;
// #define A a
import "C"
import "fmt"

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

The above code doesn't work on tip, but does work on 1.9.
Maybe we should call it regression. I'll let others to decide.

@odeke-em odeke-em changed the title cmd/cgo: 'a' and 'r' cannot be used as C fucntion name cmd/cgo: 'a' and 'r' cannot be used as C function name Jan 7, 2018
@golang golang locked and limited conversation to collaborators Jun 18, 2019
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