-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: cgo + static const int results in "undefined reference" on linux #40820
Comments
This seemed to be working at |
|
@cherrymui in this case what would be the recommended way to keep the Go consts in sync with their C counterparts - outside of redefining them which will be a maintenance nightmare ? This code also compiles and works on darwin with no issues. |
I think this is also mentioned in #39136. One difference is that GCC emits a static const int BAR = 1;
enum { V = (BAR) * 1 }; clang compiles the code without error but GCC reports
I'm not sure why clang doesn't give an error in that case. clang's behavior seems correct for C++ but not for C. Note that using |
I found the commit that broke it, da76981 |
It's been 3 years, any word on this? |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Have not tried
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Linking of a program referring to
static const int
fails withundefined reference
:foo.h
foo.go
What did you expect to see?
Compilation succeeds on linux as it does on darwin
What did you see instead?
The text was updated successfully, but these errors were encountered: