2013-07-05 89 views
2

我通常會建議考慮警告爲錯誤。我使用Boost C++ 1.54.0和MinGW 4.8.1,特別是我使用ptree。MinGW和Boost C++ 1.54.0警告

#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: \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 

是無視這種警告的方法嗎?

+0

那是因爲你有'-Wunused-local-typedefs'編譯選項就把它刪除,一切都很好! – Boynux

+0

我alawys用-Wall構建,不幸的是gcc不允許選擇警告。 –

+1

這個問題似乎是在啓動,嘗試編譯沒有'-Wall'並查看結果!你也可以使用'-Wno-unused-local-typedefs'我不確定它是否有效! – Boynux

回答

8

GCC允許自4.6

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

仍然有一些警告,無法以這種方式被turend關閉忽略特定的警告,但它適用於大多數

或不喜歡它提到,並添加其他 - Wno-unused-local-typedefs到命令行