来自提升的警告
Warnings from boost
本文关键字:警告 更新时间:2023-10-16
我有很多来自提升库标头的警告,有什么办法可以解决这个问题吗?
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
更新:
这个类似问题的解决方案看起来很合理:https://stackoverflow.com/a/1900578/1179925
主要问题是来自第三方或系统头文件的(大量)警告,可以(大多数时候)安全地忽略。我的解决方案是将我的源文件命名为*.cpp
和*.hpp
,并添加其他头文件*.cpp.h
和*.hpp.h
,以包含警告生成头文件,如下所示:
#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++编译器。
对于Visual Studio,警告pragma
可以放入"正常"头文件和源文件中,但对于GCC,这将不起作用。对于 GCC,第 pragma GCC system_header
行将整个头文件声明为系统头文件,其中警告将被忽略。当然,这不是一个系统头文件,但它应该只包括那些,其中提升头文件有点像。
当然:向解决方案中添加更多头文件远非一个优雅的解决方案。但它有效。
相关文章:
- 警告处理为错误这里有什么问题
- 使用动态分配的数组会导致代码分析发出虚假的C6386缓冲区溢出警告
- cppcheck在const std::string[]上引发警告
- GCC对可能有效的代码抛出init list生存期警告
- 如何在BST的这个简单递归实现中消除警告
- 关于std::move的使用,是否有编译警告
- g++ 在某个类成员未初始化时不发出警告
- 如何处理来自核心指南检查器的关于gsl::at的静态分析警告
- 使用typeid警告未使用的变量
- 示例C++项目编译中的警告
- 警告:在函数返回类型 [-Wignore 限定符] 时忽略类型限定符
- 如何修复编译器警告 C6386 和 C6385?
- 返回语句后的代码,没有警告
- 获取隐式转换溢出从无符号到已签名的警告
- 编译器警告:执行到达值返回函数的末尾而不返回值
- 在未链接的部分上生成警告
- 警告 C4552:">>":未使用表达式的结果
- 禁止显示由于常量为零而比较始终为假的警告
- C++ 警告:将新创建的 gsl::owner<> 分配给非所有者
- 为什么布尔开关语句有编译器警告?