2012-04-09 122 views
1

我正在使用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); }); 

好像總是錯誤以'});'結尾的一行出現。完整的代碼在這裏顯示的內容相當龐大,而且可以在其他計算機上運行,​​所以推測這是我的設置或其他問題。任何人都可能猜測他們可能是什麼?

+0

檢查ANSI代碼頁。 – Joshua 2012-04-09 20:16:36

+1

你的編譯器是否支持C++ 11? – juanchopanza 2012-04-09 20:20:17

+2

VS的相同補丁級別? – 0xC0000022L 2012-04-09 20:36:14

回答

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

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這是因爲這兩個品種的命名空間和boost ::蓄電池具有相同的功能「的意思是」

我希望這有助於

相關問題