3

今天我重建了我的 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 library 中的问题,我无法编译应用程序的其余部分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 类相同的错误......</p>

谢谢!

4

1 回答 1

3

我怀疑你已经被 gcc 4.7 中模板实例化的两阶段查找规则的变化所困扰。

如果没有源代码,我无法给出任何更实用的建议,但gcc4.7 更改(C++ 章)给出了两阶段查找的描述并建议了一些代码更正。

于 2012-04-05T11:18:25.277 回答