我有一个使用 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
更多推荐
如何禁止包含的警告?
发布评论