如何禁止包含的警告?

编程入门 行业动态 更新时间:2024-10-11 17:24:18
本文介绍了如何禁止包含的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用 tinyxml2 库的项目.我有很长的编译器选项列表,其中列出了 -Werror = zero-as-null-pointer-constant .因此,在所有包含 tinyxml2.h 的地方,我都有错误: 0用作空指针,但是我的代码没有这样的问题.是否有一种方法可以禁用某些包含项的编译器选项,因为我无法控制它们?

I have a project which uses tinyxml2 library. I have a very long list of compiler options where the -Werror=zero-as-null-pointer-constant is listed among others. So, everywhere I include the tinyxml2.h I have the errors: 0 used as null pointer, however my code does not have such problems. Is there a way to disable some compiler options for the includes because I can't control them?

P.S.如果不可能通过 gcc/clang 选项进行操作,也许可以通过cmake进行操作?或者我想知道这两种方式是否存在.

P.S. If it is impossible to do via gcc/clang options, perhaps it is possible to do via cmake? Or I would like to know both ways if they are exist.

推荐答案

您可以使用抑制编译指示.

You could use suppression pragmas.

GCC和VC ++编译器支持此功能,如下所示:

This is supported for GCC and VC++ compilers, and it looks like this:

#pragma warning(push) #pragma warning(disable : 4244) #pragma warning(disable : 4127) #pragma warning(disable : 4512) #include <boost/python.hpp> #pragma warning(pop)

以下是详细规格:

  • VC ++
  • GCC

更多推荐

如何禁止包含的警告?

本文发布于:2023-11-09 07:41:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!