elv*_*kaj 2 boost warnings c++11
我通常建议将警告视为错误.我正在使用Boost C++ 1.54.0和MinGW 4.8.1,特别是我正在使用ptree.
#include <iostream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这个简单的程序会导致以下错误:
typedef 'cons_element' locally defined but not used [-Wunused-local-typedefs] line 228, external location: \boost\tuple\detail\tuple_basic.hpp
typedef 'Str' locally defined but not used [-Wunused-local-typedefs] line 38, external location: \boost\property_tree\detail\xml_parser_write.hpp
typedef 'Str' locally defined but not used [-Wunused-local-typedefs] line 72, external location: \boost\property_tree\detail\xml_parser_write.hpp
typedef 'T_must_be_placeholder' locally defined but not used [-Wunused-local-typedefs] line 37, external location: \boost\bind\arg.hpp
Run Code Online (Sandbox Code Playgroud)
是一种忽略此警告的方法吗?
gcc允许忽略4.6以来的特定警告
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
...
...
#pragma GCC diagnostic pop
Run Code Online (Sandbox Code Playgroud)
还有一些警告无法通过这种方式进行处理,但它适用于大多数情况
或者像提到的那样做,并在命令行中添加-Wno-unused-local-typedef
| 归档时间: |
|
| 查看次数: |
1696 次 |
| 最近记录: |