让一个gcc警告一个错误? [英] Make one gcc warning an error?

查看:464
本文介绍了让一个gcc警告一个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从GCC得到这个警告:


警告:不能传递非POD类型的对象'class Something'through'.. ';调用将在运行时中止


这非常致命,特别是因为它会调用中止。为什么这不是一个错误?我想使它成为一个错误,但:


  1. 如何为特定警告提供错误?

  2. 有哪个警告?根据 http://gcc.gnu.org/onlinedocs/gcc/Warning-Options .html -Wno-invalid-offsetof 看起来像是隐藏它的标志,但它不是

>

解决方案

我不确定什么是正确的警告,但是一旦您找到它,您可以使用以下以'format'为例):

  #pragma GCC诊断错误-Wformat

 > gcc -Werror = format ... 

编辑:只是检查了这个gcc源代码,这个特定的警告不能通过命令行标志禁用。


I get this warning from GCC:

warning: cannot pass objects of non-POD type 'class Something' through '...'; call will abort at runtime

It's pretty deadly, especially since it calls an abort. Why isn't this an error? I would like to make it an error, but:

  1. How do I make a specific warning an error?
  2. Which warning is it? According to http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html, -Wno-invalid-offsetof looks like the flag to hide it, but it doesn't

解决方案

I'm not sure what the correct warning is, but once you've found it, you can change it's disposition with the following (using 'format' as the example):

#pragma GCC diagnostic error "-Wformat"

Or as strager points out:

gcc -Werror=format ...

Edit: I've just checked the gcc source for this and this specific warning cannot be disabled via command line flags.

这篇关于让一个gcc警告一个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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