cmd/cgo: go build failed on _cgo_main.c if there's '#cgo CFLAGS: -W -Werror' in cgo preamble #43639
Labels
Milestone
Comments
hzzb
added a commit
to hzzb/go
that referenced
this issue
Jan 12, 2021
Applying -Werror compiler option to request warnings is an usual way to discover potential errors. Go user may put a cgo directive in preamble: `// #cgo CFLAGS: -Werror=unused-parameter`. However, the directive also takes effect on the cgo generated files. I cleaned _cgo_main.c to help Go user only concentrate on warnings of their own file. Fixes golang#43639
Change https://golang.org/cl/283232 mentions this issue: |
hzzb
added a commit
to hzzb/go
that referenced
this issue
Jan 12, 2021
Applying -Werror compiler option to request warnings is an usual way to discover potential errors. Go user may put a cgo directive in preamble: `// #cgo CFLAGS: -Werror=unused-parameter`. However, the directive also takes effect on the cgo generated files. I cleaned _cgo_main.c to help Go user only concentrate on warnings of their own file. Fixes golang#43639
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
demo code: https://play.golang.org/p/JybuNyX-bqf
cd to the package directory containing above two files and run
go build
What did you expect to see?
go build ran successfully and nothing outputted
What did you see instead?
_cgo_main.c:2:23: error: unused parameter 'fn' [-Werror,-Wunused-parameter]
_cgo_main.c:2:61: error: unused parameter 'a' [-Werror,-Wunused-parameter]
_cgo_main.c:2:68: error: unused parameter 'c' [-Werror,-Wunused-parameter]
_cgo_main.c:2:85: error: unused parameter 'ctxt' [-Werror,-Wunused-parameter]
_cgo_main.c:4:41: error: unused parameter 'ctxt' [-Werror,-Wunused-parameter]
_cgo_main.c:6:26: error: unused parameter 'a' [-Werror,-Wunused-parameter]
_cgo_main.c:6:33: error: unused parameter 'c' [-Werror,-Wunused-parameter]
_cgo_main.c:7:23: error: unused parameter 'a' [-Werror,-Wunused-parameter]
_cgo_main.c:7:30: error: unused parameter 'c' [-Werror,-Wunused-parameter]
The text was updated successfully, but these errors were encountered: