Q: cgo how to suppress warnings I have a cgo application that uses a C library. During the build process, the compiler shows some warnigns:
In file included from ./libsolv-sys/src/qsort_r.c:40:0,
                 from ./libsolv-sys/src/util.c:181,
                 from ./libsolv.go:16:
/usr/include/sys/cdefs.h:1:2: warning: #warning usage of non-standard #include <sys/cdefs.h> is deprecated [-Wcpp]
 #warning usage of non-standard #include <sys/cdefs.h> is deprecated
  ^~~~~~~

This library is not maintained by myself and I am not able to fix this warning directly. I am sick of the warning though.
Question: How do I suppress warnings in CGO?
Used CGO Flags:
CFLAGS: -I./libsolv-sys/src -D LIBSOLV_INTERNAL
LDFLAGS: ${SRCDIR}/libsolv-sys.a

A: CGO relies on an external compiler toolchain to compile your C code.
On my Linux machine for example, it will default to GCC to compile C code.
For gcc the flag you are looking for is -w, so your flags would be:
-I./libsolv-sys/src -D LIBSOLV_INTERNAL -w
reference: Disable all gcc warnings
You may need another flag if you are using another toolchain.
