Skip to content

Commit fafd447

Browse files
ianlancetaylorgopherbot
authored andcommitted
cmd/cgo: use full prototype for main in C code
Avoids pedantic errors from modern C compilers. Fixes #70769 Change-Id: Ibe0d9960e998eb0346b97d7bd69eb7de0d0e6c60 Reviewed-on: https://go-review.googlesource.com/c/go/+/635095 Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Mauri de Souza Meneguzzo <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Commit-Queue: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 0ca521f commit fafd447

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/cmd/cgo/doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ Instead, the build process generates an object file using dynamic
796796
linkage to the desired libraries. The main function is provided by
797797
_cgo_main.c:
798798
799-
int main() { return 0; }
799+
int main(int argc, char **argv) { return 0; }
800800
void crosscall2(void(*fn)(void*), void *a, int c, uintptr_t ctxt) { }
801801
uintptr_t _cgo_wait_runtime_init_done(void) { return 0; }
802802
void _cgo_release_context(uintptr_t ctxt) { }

src/cmd/cgo/out.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (p *Package) writeDefs() {
5959

6060
// Write C main file for using gcc to resolve imports.
6161
fmt.Fprintf(fm, "#include <stddef.h>\n") // For size_t below.
62-
fmt.Fprintf(fm, "int main() { return 0; }\n")
62+
fmt.Fprintf(fm, "int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) { return 0; }\n")
6363
if *importRuntimeCgo {
6464
fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*) __attribute__((unused)), void *a __attribute__((unused)), int c __attribute__((unused)), size_t ctxt __attribute__((unused))) { }\n")
6565
fmt.Fprintf(fm, "size_t _cgo_wait_runtime_init_done(void) { return 0; }\n")

0 commit comments

Comments
 (0)