所以我正在处理一个非常大的代码库,最近升级到 gcc 4.3,现在触发了这个警告:
So I'm working on an exceedingly large codebase, and recently upgraded to gcc 4.3, which now triggers this warning:
警告:不推荐将字符串常量转换为‘char*’
warning: deprecated conversion from string constant to ‘char*’
显然,解决这个问题的正确方法是找到每个声明,如
Obviously, the correct way to fix this is to find every declaration like
char *s = "constant string";
或函数调用,如:
void foo(char *s);
foo("constant string");
并使它们成为 const char
指针.但是,这意味着最少要接触 564 个文件,这不是我目前希望执行的任务.现在的问题是我使用 -werror
运行,所以我需要一些方法来抑制这些警告.我该怎么做?
and make them const char
pointers. However, that would mean touching 564 files, minimum, which is not a task I wish to perform at this point in time. The problem right now is that I'm running with -werror
, so I need some way to stifle these warnings. How can I do that?
我相信将 -Wno-write-strings
传递给 gcc 会抑制这个警告.
I believe passing -Wno-write-strings
to gcc will suppress this warning.
这篇关于如何在 GCC 中摆脱“已弃用的从字符串常量到‘char*’的转换"警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!