首页 > 解决方案 > Boost_1_72_0 错误:宏“test”传递了 2 个参数,但只需要 1 个

问题描述

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11) centos-release-7-3.1611.el7.centos.x86_64 提升:1.72.0

编译我的 c++ 代码时出现以下错误:

In file included from /home/hadoop/work/external-lib/boost_1_72_0/boost/mpl/apply_wrap.hpp:23:0,
                 from /home/hadoop/work/external-lib/boost_1_72_0/boost/mpl/apply.hpp:23,
                 from /home/hadoop/work/external-lib/boost_1_72_0/boost/iterator/iterator_facade.hpp:36,
                 from /home/hadoop/work/external-lib/boost_1_72_0/boost/range/iterator_range_core.hpp:27,
from /home/hadoop/work/external-lib/boost_1_72_0/boost/algorithm/string/replace.hpp:16,
from /home/hadoop/work/external-lib/boost_1_72_0/boost/date_time/date_facet.hpp:17,
from /home/hadoop/work/external-lib/boost_1_72_0/boost/date_time/gregorian/gregorian_io.hpp:16,
from /home/hadoop/work/external-lib/boost_1_72_0/boost/date_time/gregorian/gregorian.hpp:31,
from /home/hadoop/work/external-lib/boost_1_72_0/boost/date_time/posix_time/time_formatters.hpp:12,
from /home/hadoop/work/external-lib/boost_1_72_0/boost/date_time/posix_time/posix_time.hpp:24,
from /home/hadoop/work/external-lib/boost_1_72_0/boost/date_time/local_time/local_time.hpp:11,
from /home/hadoop/work/external-lib/boost_1_72_0/boost/date_time.hpp:15,
from /home/hadoop/work/db/connection.cpp:6:
/home/hadoop/work/external-lib/boost_1_72_0/boost/mpl/aux_/has_apply.hpp:22:58: error: macro "test" passed 2 arguments, but takes just 1
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_apply, apply, false)

db/connection.cpp 文件是:

#include "connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <boost/date_time.hpp> // Error at this line

db::Connection::Connection() {
        m_driver = sql::mysql::get_mysql_driver_instance();
        m_driver->threadInit();
        m_con = m_driver->connect("tcp://<host>:<port>", "<user>", "<pwd>");
        m_con->setSchema("test");
        m_stmt = m_con->createStatement();
}

我不打任何 boost::date_time 电话。只包括头文件(暂时)。

值得一提的是,MySQL 代码也访问了 boost 库(内部),当我注释掉 boost/date_time 头文件时,我没有收到任何错误。

标签: c++boost

解决方案


推荐阅读