c - 如何在 Linux 中抑制 -Werror=pointer-to-int-cast 和 -Werror=address 类型的错误

标签 c linux gcc gnu

如何在 Linux 中抑制 -Werror=pointer-to-int-cast-Werror=address 类错误?

我知道下面是用于抑制上述错误的选项。

-Wno-error=address
-Wno-pointer-to-int-cast

但我的问题是在构建大型项目时如何使用它们或在何处编辑编译器设置。

最佳答案

如果您使用的是标准 Makefile 构建系统,请将它们放入 CFLAGS。

如果是autoconf工程,像这样放到Makefile.am中:

CFLAGS = -Wno-error=address -Wno-pointer-to-int-cast

如果您使用其他构建系统,则在将 .c 文件编译为 .o 时需要将其传递给 gcc 命令行。

如果它是一个使用 autoconf 的现有包,你可以像这样将它传递给 ./configure:

$ ./configure --extra-cflags='-Wno-error=address -Wno-pointer-to-int-cast'

其他基于 autoconf 的项目从环境中获取它而不是(或除了)--extra-cflags:

$ CFLAGS='-Wno-error=address -Wno-pointer-to-int-cast' ./configure --any-other-options-you-need

关于c - 如何在 Linux 中抑制 -Werror=pointer-to-int-cast 和 -Werror=address 类型的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25791680/

相关文章:

c++ - LD搜索共享库两次,并忽略加载的实例

c++ - GCC:检查是否编译为库或可执行文件

linux - 从 Dockerfile 安装 Apache

linux - QML 动画有些撕裂

GCC 生成无用指令?

c++ - Linux/海湾合作委员会 : Is there a way to check if a build is identical to a previous one on a different machine?

c - 如何使用 char* 作为 char[]

c++ - 在 Intellij IDEA for Windows 中配置 C++ SDK

c - arp请求和回复使用c socket编程

ios - 迭代包含 "Extended ASCII"个字符的 const unsigned char *