所有编译器:禁用某些标头的警告

时间:2018-09-29 18:24:41

标签: c++ gcc clang

我有一个跨平台项目。它是使用不同的编译器(gcc,clang,msvc ++)进行编译的。

就目前而言,我唯一的警告问题是由于Boost标头。 Gcc为我为Android平台编译的项目生成了一堆。

我想做的是禁用Boost标头的所有警告生成(因为这对我来说是无用的东西)。

因此,我创建了以下两个文件:

compiler_warnings_pop.h

//WARNING: no #pragma once here
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#elif defined(_MSC_VER)
#pragma warning(pop)
#endif

compiler_warnings_push.h

//WARNING: no #pragma once here
#if defined(__clang__)
#pragma clang diagnostic push
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#elif defined(_MSC_VER)
#pragma warning(push)
#endif

现在,我需要一个可以暂时禁用任何编译器所有警告的代码。有一个吗?所以我可以使用以下代码:

#include <compiler_warnings_push.h>
#include <compiler_warnings_disable.h>
#include <boost/...>
#include <compiler_warnings_pop.h>

0 个答案:

没有答案