如何禁用特定包含文件的警告? [英] How to disable warnings for particular include files?

查看:281
本文介绍了如何禁用特定包含文件的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要对特定include档案直接或间接包含的所有档案停用特定警告。例如,对于 #include< bar / *> 包含的文件包含的所有文件或文件,我要禁用警告您要为char *指定一个字符串文字 code>(我的情况下的星标意味着任何东西都可能在这里)。

I wold like to disable particular warnings for all files that are included, directly or indirectly, by particular include files. For example, I want to disable the warning "you are assigning a string literal to a char*", for all files or files included by files included by a #include <bar/*> (the star in my case means "anything may be here").

原因是,我要编程的一些人不能使用const,所以最后我得到了很多关于该特定字符串的警告文字滥用。我想忽略来自他们的代码的成千上万的警告,所以我可以集中精力在我自己的代码中的错误,并解决它们。

The reason is, some of the people I have to program with just can't use "const", so in the end I get lots of warnings about that particular string literal abuse. I would like to ignore those thousands of warnings coming from their code, so I can concentrate on the mistakes in my own code and fix them.

我使用Intel C ++和GCC。我的一些朋友使用ang,所以我很高兴听到这个解决方案。

I use Intel C++ and GCC. Some of my buddies use clang, so I would be glad to hear solutions for that too.

推荐答案

使用GCC时,您可以使用 -isystem -I 标志以禁用该位置的警告。

When using GCC you can use the -isystem flag instead of the -I flag to disable warnings from that location.

因此,如果您目前使用

gcc -Iparent/path/of/bar …

使用

gcc -isystem parent/path/of/bar …

不幸的是,这不是一个特别细粒度的控制。我不知道有更有针对性的机制。

instead. Unfortunately, this isn’t a particularly fine-grained control. I’m not aware of a more targeted mechanism.

这篇关于如何禁用特定包含文件的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆