2018-09-20 21:19
浏览 144


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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpd7195 2018-09-20 23:05

    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.

    点赞 评论

相关推荐 更多相似问题