dsjzmrz78089 2018-09-20 21:19
浏览 173
已采纳

CGO如何抑制警告

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!