【发布时间】:2023-03-19 08:12:01
【问题描述】:
在使用默认 gcc 编译器(版本 4.8.5)的 Centos7 上,我从头开始构建 boost 1.71.0 64bit。构建过程中没有出现问题;一切正常。 当我尝试编译使用 boost 的源代码时(在我的例子中是 boost/thread.hpp),我得到一个编译错误:
boost/bind/storage.hpp:44:40: error: macro "accept" requires 3 arguments, but only 1 given
template<class V> void accept(V & v) const
^
编译器开关是:
g++ -c -Wall -Wno-error -fPIC -g -O0 -D WITH_XXTGNOME_TRACE -D DEBUG -D_PTHREADS=1 -D_REENTRANT=1 -m64 -std=gnu++11
后跟包含路径。
使用 VS 2017 编译相同的源代码没有错误。有人知道出了什么问题吗?
【问题讨论】:
-
在godbolt 上工作,请提供minimal reproducible example。您(或您包含的其他一些库)可能定义了一个名为
accept的宏,它正在破坏提升,例如godbolt.org/z/qAJBQw -
这就是解决方案!定义了另一个同名的 makro,它没有在 Windows 中使用(#ifndef _WIN32 ...)。谢谢。