Boost突然进入我的命名空间,声称由于缺少函数而出现错误

Boost suddenly getting into my namespace, claiming errors for lack of functions

本文关键字:函数 于缺少 错误 突然 我的 命名空间 Boost      更新时间:2023-10-16

在传奇故事"Me vs Boost,libconfig,protocol buffers and glog"的新一集中,我们发现我们的主角(我)正在为争夺命名空间的所有权而与Boost进行殊死搏斗!。

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

server.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!。

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

任何帮助都将不胜感激!,

朱利安。

可能是您在之前包含的一个标头中的错误,该标头没有正确关闭命名空间。