-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: document preamble/export restriction #3497
Labels
Milestone
Comments
If I split your file into two, it works: # ls a.go b.go # cat a.go package main /* #include <stdio.h> extern void AGoFunction(); void ACFunction() { printf("ACFunction()\n"); AGoFunction(); } */ import "C" func main() { C.ACFunction() } # cat b.go package main import "fmt" import "C" //export AGoFunction func AGoFunction() { fmt.Println("AGoFunction()") } # go run a.go b.go ACFunction() AGoFunction() # I think, your program is breaking rule described in http://golang.org/doc/articles/c_go_cgo.html: "... There is a limitation: if your program uses any //export directives, then the C code in the comment may only include declarations (extern int f();), not definitions (int f() { return 1; }). ...". It further says "... The #cgo and //export directives are documented in the cgo documentation.", but I couldn't find any info about "export directive limitation" in http://golang.org/cmd/cgo/. So, perhaps, documentation is lacking. Also, example in http://code.google.com/p/go-wiki/wiki/cgo is, obviously, wrong too. Leaving for others to decide what to do. Alex Labels changed: added cgo. |
The restriction is new in Go 1, and it is mentioned at http://golang.org/doc/go1.html#cmd_cgo, but we neglected to add it to the cgo doc proper. Labels changed: added priority-later, documentation, go1.1, removed priority-triage. Status changed to Accepted. |
This issue was closed by revision ed9fc75. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by wilson.oliveira:
The text was updated successfully, but these errors were encountered: