今天我重建了我的C ++应用程序并且编译失败了。但是没有任何改变。第一个错误发生在我的类List
中,它继承自std::vector
(私有继承):
template<typename T> void List<T>::append(const T& value)
{
push_back(value);
}
我必须在std::vector<T>::
之前添加push_back(value);
,因为编译器没有找到声明。我真的不知道它为什么会发生,但是有了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
与我的List类相同的错误...
谢谢!
答案 0 :(得分:3)
我怀疑你被gcc 4.7中模板实例化的两阶段查找规则的变化所困扰。
如果没有源代码,我无法提供更实用的建议,但是gcc4.7 changes(C ++章节)给出了两个阶段查找的描述并建议了一些代码更正。