-
Notifications
You must be signed in to change notification settings - Fork 18k
doc: for -buildmode=c-shared, document that //export requires import "C" #11955
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
Comments
You need to actually import "C" in the file with the //export comment. Otherwise cgo is not invoked and the //export comment is ignored. |
Thanks Ian! Misunderstanding on my part - I didn't realize I see you added the Would it be feasible to recognize that no user code is being exported and produce a warning to point them in the right direction? If the developer is using |
I can't think of a simple way to check for no functions being exported, and I'm not sure it's worth coming up with a complex way. The fact that it doesn't work will be obvious. |
CL https://golang.org/cl/13080 mentions this issue. |
CL https://golang.org/cl/13096 mentions this issue. |
I accidentally submitted https://golang.org/cl/13080 too early. Update #11955. Change-Id: I1a5a6860bb46bc4bc6fd278f8a867d2dd9e411e1 Reviewed-on: https://go-review.googlesource.com/13096 Reviewed-by: Andrew Gerrand <[email protected]>
This may just be a misunderstanding of how this is supposed to work - if so I'd appreciate some guidance.
What version of Go are you using (go version)?
go version go1.5beta3 darwin/amd64
What operating system and processor architecture are you using?
Mac OS X 10.10.4 Intel Core i7
What did you do?
I'm trying to build a C archive to link to a C++ app. I read the release notes and the Go Execution Modes doc. The second document states:
I wrote a small test:
go build -buildmode=c-archive
What did you expect to see?
I expected it to create foo.a and a header file with Foo exported.
What did you see instead?
It generated foo.a, but no header file.
nm also doesn't show my function being exported:
The text was updated successfully, but these errors were encountered: