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.

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

报告相同问题?

悬赏问题

  • ¥100 高价邀请复制 域天d8联网狗
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?