diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 00e2f9769c..1a6f17cedd 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -776,6 +776,10 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { fmt.Fprintf(fgcc, "#include \n") fmt.Fprintf(fgcc, "#include \"_cgo_export.h\"\n\n") + // We use packed structs, but they are always aligned. + fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Wpragmas\"\n") + fmt.Fprintf(fgcc, "#pragma GCC diagnostic ignored \"-Waddress-of-packed-member\"\n") + fmt.Fprintf(fgcc, "extern void crosscall2(void (*fn)(void *, int, __SIZE_TYPE__), void *, int, __SIZE_TYPE__);\n") fmt.Fprintf(fgcc, "extern __SIZE_TYPE__ _cgo_wait_runtime_init_done();\n") fmt.Fprintf(fgcc, "extern void _cgo_release_context(__SIZE_TYPE__);\n\n") @@ -1473,6 +1477,10 @@ __cgo_size_assert(double, 8) extern char* _cgo_topofstack(void); +/* We use packed structs, but they are always aligned. */ +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" + #include #include `