c - 启用 gcc 对文字字符溢出的警告

标签 c gcc warnings

在 gcc 中,即使打开了 -Wall,我也没有收到以下警告:char x = 0xff;

但是对于-迂腐,我愿意。

有没有办法打开此警告,而不使用迂腐的警告并收到其他迂腐的警告?

最佳答案

我不确定是否还有另一个FLAG,如果你不想使用-pedantic/-Wpedantic,你可以尝试这样的事情:

error: conversion to ‘char’ alters ‘int’ constant value [-Werror=conversion]
 char x = 0xff;
          ^

如果是,则执行:

gcc -Wconversion

关于c - 启用 gcc 对文字字符溢出的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39998786/

相关文章:

c - 复杂数据类型的内存分配

c - 使用 openssl 以编程方式提取 pem 证书信息

c - 警告 : comparison with string literals results in unspecified behaviour

c - 链接时加载符号文件

php - 如何防止第 11 行...中给出的此错误 : Warning: mysql_fetch_assoc() expects parameter 1 to be resource, bool 值

ios - UISearchBar textDidChange 创建错误 : There are visible views left after reusing them all: { (null) = (null); }

c++ - 如何将gcc中的静态库与其他动态库链接起来?

c - 防止宏的 GCC 警告 "value computed is not used"

eclipse - 如何通过Eclipse向g++添加 '-pthread'选项?

scala - 如何禁用 Scala 警告 "The outer reference in this type test cannot be checked at run time"