1

I am using gcc 4.1.2 on Linux, and I encountered the following warning:

warning: type qualifiers ignored on function return type

I tried to use "-Wno-ignored-qualifiers" to get rid of this warning but it seems not supported:

cc1: error: unrecognized command line option "-Wno-ignored-qualifiers"

Is there a way to disable such warnings in gcc 4.1.2?

Thanks a lot.

4

2 回答 2

1

找到了解决方案。利用:

-Wno-return-type
于 2013-03-13T21:20:09.680 回答
1

如此处所示, aconst char *不会触发该警告

如果const char可能的话,避免该警告的正确方法是将返回类型从 更改const charchar

请参阅Junio C Hamano ( )为 Git 2.16(2018 年第一季度)提交的 ee5462d(2017 年 12 月 27 日)示例。gitster

sequencer.cconst:从函数返回类型中删除“ ”

使用-Werror=ignored-qualifiers,声称返回 " const char" 的函数会出现此错误:

   CC sequencer.o
sequencer.c:798:19: error: type qualifiers ignored on function return
type [-Werror=ignored-qualifiers]
 static const char command_to_char(const enum todo_command command)
                   ^
于 2017-12-28T15:55:07.953 回答