从boost警告 [英] Warnings from boost

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

问题描述

我有很多从boost库头警告,有没有什么办法来解决这个问题呢?

I have lots of warning from boost library headers, is there any way to resolve this problem?

libs/boost/include/boost/numeric/ublas/detail/vector_assign.hpp:382:39: warning: typedef ‘reference’ locally defined but not used [-Wunused-local-typedefs]
         typedef typename V::reference reference;

libs/boost/include/boost/numeric/ublas/detail/vector_assign.hpp:516:40: warning: typedef ‘value_type’ locally defined but not used [-Wunused-local-typedefs]
         typedef typename V::value_type value_type;

libs/boost/include/boost/numeric/ublas/detail/matrix_assign.hpp:644:40: warning: typedef ‘value_type’ locally defined but not used [-Wunused-local-typedefs]
         typedef typename M::value_type value_type;

libs/boost/include/boost/numeric/ublas/operation.hpp:132:26: warning: typedef ‘expression2_type’ locally defined but not used [-Wunused-local-typedefs]
         typedef const E2 expression2_type;

libs/boost/include/boost/numeric/ublas/operation.hpp:191:26: warning: typedef ‘expression1_type’ locally defined but not used [-Wunused-local-typedefs]
         typedef const E1 expression1_type;

libs/boost/include/boost/numeric/ublas/operation.hpp:193:39: warning: typedef ‘size_type’ locally defined but not used [-Wunused-local-typedefs]
         typedef typename V::size_type size_type;

如果它的事项我的的gcc --version

gcc (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1

更新:

这解决了类似的问题,看起来合理的: http://stackoverflow.com/a/1900578/1179925

This solution to similar problem looks resonable: http://stackoverflow.com/a/1900578/1179925

推荐答案

主要的问题是(大量的)来自第三方或系统头文件的警告,可以(大部分时间)安全地忽略。我对这个解决方案来命名我的源文件 *。CPP *。HPP 并添加额外的头文件<$ 。C $ C> * cpp.h 和 * hpp.h 为包括生产的头文件是这样的警告:

The main problem is (lots of) warnings from 3rd party or system header files that can (most of the time) safely be ignored. My solution to this was to name my source files *.cpp and *.hpp and added additional header files *.cpp.h and *.hpp.h for including warning producing header files like this:

#pragma once

#if defined __GNUC__
#   pragma GCC system_header
#elif defined __SUNPRO_CC
#   pragma disable_warn
#elif defined _MSC_VER
//# pragma warning(push, 0)
#   pragma warning(push)
#   pragma warning(disable : 4800)
//# pragma warning(disable : ...)
#endif

// BEGIN INCLUDING 3RD PARTY HEADERS
#include <QApplication>
#include <QTextCodec>
#include <QTranslator>
#include <QLocale>
//#include <boost/someboostheader.hpp>
// END INCLUDING 3RD PARTY HEADERS

#if defined __SUNPRO_CC
#   pragma enable_warn
#elif defined _MSC_VER
#   pragma warning(pop)
#endif

这应该与海湾合作委员会和Visual Studio至少工作,因为我从来没有测试过太阳C ++编译器。

This should work at least with GCC and Visual Studio since I've never tested the Sun C++ compiler.

有关Visual Studio中的警告编译 S需要投入的正常头文件和源文件,但GCC将无法正常工作。随着GCC行编译GCC system_header 宣布,整个头文件作为系统头文件,其中警告将被忽略。当然,这不是系统头文件,但它应该只包括那些,这提振头文件一种是。

For Visual Studio the warning pragmas could be put into the "normal" header and source files, but for GCC that won't work. With GCC the line pragma GCC system_header declares that entire header file as system header file where warnings would be ignored. Of course this is not a system header file, but it is supposed to only include those, which boost header files kind of are.

当然:加入一些更头文件到您的解决方案是远非完美的解决方案。但它的作品。

Of course: adding some more header files to your solution is far from being an elegant solution. But it works.

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

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