MinGW and Boost C++ 1.54.0 warnings



我通常会将警告视为错误进行构建。我使用的是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;
}

这个简单的程序会导致以下错误:

typedef 'cons_element' locally defined but not used [-Wunused-local-typedefs] line 228, external location: boosttupledetailtuple_basic.hpp  
typedef 'Str' locally defined but not used [-Wunused-local-typedefs] line 38, external location: boostproperty_treedetailxml_parser_write.hpp
typedef 'Str' locally defined but not used [-Wunused-local-typedefs] line 72, external location: boostproperty_treedetailxml_parser_write.hpp
typedef 'T_must_be_placeholder' locally defined but not used [-Wunused-local-typedefs]      line 37, external location: boostbindarg.hpp

有没有办法忽略这些警告?

gcc允许忽略自4.6 以来的特定警告

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
...
...
#pragma GCC diagnostic pop

仍然有一些警告不能通过这种方式获得,但它适用于大多数

或者像其他提到的一样,将-Wno未使用的本地typedefs添加到命令行

最新更新