什么可能导致一台计算机上的模糊符号错误而不是另一台计算机?

时间:2012-04-09 20:15:34

标签: c++ visual-studio-2010 compiler-errors

我正在使用Visual Studio 2010来处理C ++代码。该项目及其所有内容均由其他人编写,并复制到共享驱动器上。当创建者在他的计算机上构建它时,它工作正常。当我尝试构建解决方案时,我得到了一大堆这些错误

error C2872: '<lambda0>' : ambiguous symbol could be 
 '[File].cpp(66) : anonymous-namespace'::<lambda0>' or 
 '[Different file].h(549) : `anonymous-namespace'::<lambda0>'. 

这是一个据说错误的行的例子:

std::pair<int, std::pair<int, Point>> b) -> bool { return (a.second.second < b.second.second ); });

似乎错误总是出现在以'})结尾的行中;'。完整的代码在这里展示相当庞大,它可以在其他计算机上运行,​​因此可能是我的设置或其他问题。任何人都可以猜测它们可能是什么吗?

3 个答案:

答案 0 :(得分:2)

不确定您是否已经看过这个,但根据MSDN页面查看该编译错误:

C2872 can occur if a header file includes a using Directive (C++), and a subsequent header file is #include'd and contains a type that is also in the namespace specified in the using directive. Specify a using directive only after all your header files are specified with #include.

MSDN Page

答案 1 :(得分:0)

我遇到了同样的问题,这是一个模糊的符号问题。对我来说,事实证明我使用了两个具有相同功能但明显不同定义的命名空间。我必须停止使用其中一个命名空间,这样才能解决问题。

举个例子:

using namespace cv;
using namespace boost::accumulator;
accumulator_set<double, stats<tag::mean, tag::variance> > acc;
double meanval = mean (acc);

这将通过编译错误:error C2872: 'mean' : ambiguous symbol这是因为命名空间cv和boost :: accumulator都具有相同的功能“mean”

我希望这会有所帮助

答案 2 :(得分:0)

我遇到了同样的问题 安装VS2010 SP1对我来说解决了模棱两可的anonymous-namespace'::<lambda0>问题。没有SP1的VS2010的lambda问题。