2012-04-04 95 views
2

今天我重建了我的C++應用程序,編譯失敗。雖然沒有改變。第一個錯誤是班裏Liststd::vector(私有繼承)繼承了這裏:編譯失敗在Boost librairies(program_options)

template<typename T> void List<T>::append(const T& value) 
{ 
    push_back(value); 
} 

我不得不push_back(value);之前添加std::vector<T>::因爲沒有聲明是由編譯器發現。我不知道它爲什麼會發生,但是有一個g ++的更新,我現在在Arch Linux上使用C++ 11使用g ++ v4.7.0(預發佈)。

我修復了這個問題,但現在真正的問題是,由於Boost庫program_options中的問題,我無法編譯應用程序的其餘部分。包括我與圖書館:

#include <boost/config.hpp> 
#include <boost/program_options/detail/config_file.hpp> 
#include <boost/program_options/parsers.hpp> 

的錯誤:

g++ -m64 -pipe -pedantic -Wextra -std=gnu++0x -c -g -Wall -DDEBUG -DDEV -DMYSQL_SUPPORT -I. -IHeaders -MMD -MP -MF build/Debug/GNU-Linux-x86/Sources/Libs/Settings.o.d -o build/Debug/GNU-Linux-x86/Sources/Libs/Settings.o Sources/Libs/Settings.cpp 
/usr/include/boost/program_options/detail/config_file.hpp: In instantiation of ‘bool boost::program_options::detail::basic_config_file_iterator<charT>::getline(std::string&) [with charT = char; std::string = std::basic_string<char>]’: 
In file included from Sources/Libs/Settings.cpp:33:0: 
Sources/Libs/Settings.cpp:69:24: required from here 
/usr/include/boost/program_options/detail/config_file.hpp:163:13: erreur: ‘to_internal’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] 
In file included from /usr/include/boost/program_options/detail/parsers.hpp:9:0, 
       from /usr/include/boost/program_options/parsers.hpp:265, 
       from Sources/Libs/Settings.cpp:34: 
/usr/include/boost/program_options/detail/convert.hpp:75:34: note: ‘template<class T> std::vector<std::basic_string<char> > boost::program_options::to_internal(const std::vector<T>&)’ declared here, later in the translation unit 

同樣的錯誤比我的列表類...

謝謝!

回答

3

我懷疑你已經被gcc 4.7中模板實例的兩階段查找規則的變化所咬。

如果沒有源代碼,我不能給出更多的實用建議,但gcc4.7 changes(C++章節)給出了兩階段查找的描述並建議一些代碼更正。

0
template<typename T> void List<T>::append(const T& value) 
{ 
    this->push_back(value); 
}