升压的警告 [英] Warnings from 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
UPDATE:
类似问题的解决方案似乎很好: a href =http://stackoverflow.com/a/1900578/1179925> http://stackoverflow.com/a/1900578/1179925
This solution to similar problem looks resonable: http://stackoverflow.com/a/1900578/1179925
推荐答案
主要的问题是(大量)从第三方或系统头文件的警告,可以(大部分时间)安全地被忽略。我的解决方案是命名我的源文件 *。cpp
和 *。hpp
并添加了额外的头文件 *。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
这至少应该与GCC和Visual Studio一起工作,因为我从来没有测试过Sun C ++编译器。
This should work at least with GCC and Visual Studio since I've never tested the Sun C++ compiler.
对于Visual Studio,警告 pragma
可以放入normal文件,但对于GCC将不工作。使用GCC, pragma GCC system_header
行将整个头文件声明为系统头文件,其中将忽略警告。当然,这不是一个系统头文件,但它应该只包括那些,提高头文件类型。
For Visual Studio the warning pragma
s 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.
这篇关于升压的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!