如何为特定目录或文件启用特定 gcc 警告?
Possible Duplicate:
Selectively disable GCC warnings for only part of a translation unit?
How to enable a specific gcc warnings for a specific directory or file ?
I want to enable -Wsign-conversion for my own files not for any other system headers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这一行应该可以做到这一点:(请参阅此处)
#pragma GCC 诊断警告“-Wsign-conversion”
将其放入受影响的文件或所有文件中包含的标头中
This line should do it: (see here)
#pragma GCC diagnostic warning "-Wsign-conversion"
Put it in the affected files or in a header that is included in all you files
如果您想在源文件之外执行此操作,则需要引用您的构建系统。例如,在 make 中,您始终可以在 Makefile 中指定直接目标:
这将优先于一般的
.c->.o
规则,因为它更具体。其他构建系统有其他方法来实现相同的规则。
简而言之,您的问题实际上是关于您的构建系统,而不是关于 gcc。
If you want to do it outside of your source file, then you need to reference your build system. E.g. in make you can always specify a direct target in the Makefile:
This will take precedence to a general
.c->.o
rule as it is more more specific.Other build systems have other methods of achieving the same rule.
In short, your question is really about your build system, and not about gcc.