C++ 如何修复与boost和VS冲突的xtime定义相关的编译器错误?
我试图编写一组代码,但遇到以下错误:C++ 如何修复与boost和VS冲突的xtime定义相关的编译器错误?,c++,visual-studio,boost,C++,Visual Studio,Boost,我试图编写一组代码,但遇到以下错误: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\chrono(736): error C2872: 'xtime' : ambiguous symbol 1> could be 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\thr/xtimec.h(23) : xtime' 1
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\chrono(736): error C2872: 'xtime' : ambiguous symbol
1> could be 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\thr/xtimec.h(23) : xtime'
1> or 'C:\Local\boost\boost/thread/xtime.hpp(35) : boost::xtime'
我怎样才能修好它
我使用的是VS2013,我想您在全局使用的是名称空间boost,因为编译器看到了两个符号
为了避免这种错误,请显式地使用名称空间boost,比如
boost::xtime
,因为您包含了所有线程库
#include <boost/thread.hpp> // includes mutex, thread_time, tss and lot's of stuff
#include//包括互斥、线程时间、tss和很多东西
如果只需要线程,则只包含该文件
#include <boost/thread/thread.hpp>
#包括
您的代码中是否有使用namespace boost
的地方?@n.m.:没有,我查过了,没有。这是我想到的第一件事,但我没有!因为这个错误在包含VS文件的文件中,可能会从某个地方调用它。你能提供完整的错误日志吗?我哪里都没有。我详细检查了代码,以确保我没有这样的东西,我相信我没有。所以在我的代码中使用名称空间boost。