Skip to content

Commit bf35167

Browse files
ianlancetaylorgopherbot
authored andcommitted
cmd/cgo: add C declaration parameter unused attribute
Fixes #71225 Change-Id: I3e60fdf632f2aa0e63b24225f13e4ace49906925 Reviewed-on: https://go-review.googlesource.com/c/go/+/642196 Reviewed-by: David Chase <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 9d6af40 commit bf35167

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/cmd/cgo/out.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
10941094
// This unpacks the argument struct above and calls the Go function.
10951095
fmt.Fprintf(fgo2, "func _cgoexp%s_%s(a *%s) {\n", cPrefix, exp.ExpName, gotype)
10961096

1097-
fmt.Fprintf(fm, "void _cgoexp%s_%s(void* p){}\n", cPrefix, exp.ExpName)
1097+
fmt.Fprintf(fm, "void _cgoexp%s_%s(void* p __attribute__((unused))){}\n", cPrefix, exp.ExpName)
10981098

10991099
fmt.Fprintf(fgo2, "\t")
11001100

test/fixedbugs/issue71225.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// build
2+
3+
//go:build cgo
4+
5+
// Copyright 2025 The Go Authors. All rights reserved.
6+
// Use of this source code is governed by a BSD-style
7+
// license that can be found in the LICENSE file.
8+
9+
package main
10+
11+
// #cgo CFLAGS: -Werror -Wunused-parameter
12+
import "C"
13+
14+
func main() {
15+
}
16+
17+
//export Fn
18+
func Fn() {
19+
}

0 commit comments

Comments
 (0)