gpt4 book ai didi

c++ - Boost 突然进入我的命名空间,声称缺少函数的错误

转载 作者:行者123 更新时间:2023-11-30 04:29:54 24 4
gpt4 key购买 nike

在“Me vs Boost、libconfig、protocol buffers 和 glog”传奇的这一新情节中,我们发现我们的主角(我)正在为命名空间的所有权而与 Boost 进行殊死的战斗!

好吧,我一直在使用这个漂亮的代码:

服务器.h

#ifndef SERVER_H
#define SERVER_H 1

#include "configuration.h"
#include "client.h"
#include "client_manager.h"
#include <string>
#include <boost/noncopyable.hpp>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>

namespace BBCP {
namespace Server {

class Server : private boost::noncopyable {
public:
Server(BBCP::App::Config const &wrapper) :
acceptor(io_service),
wrapper(wrapper)
//signals(io_service),
{ }
void run();
protected:
void acceptHandler(boost::system::error_code const &error);
void startAccept();
void stopServer();
private:
boost::asio::io_service io_service;
boost::asio::ip::tcp::acceptor acceptor;
boost::asio::ip::tcp::endpoint endpoint;
//boost::asio::signal_set signals;

BBCP::Server::client_ptr newClient;
BBCP::Server::ClientManager manager;

boost::thread_group client_pool;
BBCP::App::Config wrapper;
};

}
}

#endif

对于现在的几个构建,它运行良好,直到之后......好吧,什么都没有,它开始出错:

In file included from /usr/include/boost/type_traits/has_nothrow_constructor.hpp:12:0,
from /usr/include/boost/optional/optional.hpp:25,
from /usr/include/boost/optional.hpp:15,
from /usr/include/boost/thread/pthread/thread_data.hpp:13,
from /usr/include/boost/thread/thread.hpp:17,
from /usr/include/boost/thread.hpp:13,
from ../include/server.h:10,
from main.cpp:17:
/usr/include/boost/type_traits/has_trivial_constructor.hpp:36:1: error: ‘has_trivial_ctor_impl’ is not a member of ‘boost::detail’
/usr/include/boost/type_traits/has_trivial_constructor.hpp:36:1: note: suggested alternative:
/usr/include/boost/type_traits/has_trivial_constructor.hpp:25:8: note: ‘BBCP::Server::boost::detail::has_trivial_ctor_impl’

(...) This goes on and on with a lot of dependencies.

现在,据我所知,BBCP::Server::boost::detail::has_trivial_ctor_impl 指的是 boost::detail 中定义的某个方法。重点是,boost::detail 不应该进入我的命名空间,BBCP::Server!

老实说,我看不出这个错误是从哪里来的,所以...

任何帮助将不胜感激!

朱利安。

最佳答案

可能是您之前包含的其中一个 header 中的一个错误,它没有正确关闭命名空间。

关于c++ - Boost 突然进入我的命名空间,声称缺少函数的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9039140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com