簡體   English   中英

G ++ 4.4編譯錯誤,較低版本有效

[英]G++ 4.4 compile error, lower versions works

我的程序是用C ++編寫的,它可以在Ubuntu 9.04上使用g ++ 4.3.4和Solaris OS with g ++ 3.4.3成功編譯。 現在我已將Ubuntu升級到版本9.10,將g ++升級到版本4.4.1。 現在編譯器調用STL中的錯誤。

/usr/include/c++/4.4/bits/stl_deque.h: In member function ‘void std::deque<_Tp, _Alloc>::swap(std::deque<_Tp, _Alloc>&)’:
In file included from /usr/include/c++/4.4/deque:65,
/usr/include/c++/4.4/bits/stl_deque.h:1404: error: ‘swap’ is not a member of ‘std’
/usr/include/c++/4.4/bits/stl_deque.h:1405: error: ‘swap’ is not a member of ‘std’
/usr/include/c++/4.4/bits/stl_deque.h:1406: error: ‘swap’ is not a member of ‘std’
/usr/include/c++/4.4/bits/stl_deque.h:1407: error: ‘swap’ is not a member of ‘std’

我不知道如何解決它,如果可能stl包含一個bug。 你能幫我嗎?

非常感謝所有的建議。

#include <algorithm>

在舊版本的GCC中,如果您包含任何標准庫標頭,則該標頭通常會包含許多其他標頭。 正如其他人所提到的,在你的情況下, <algorithm>被包含在這種方式中。

標准不要求此行為。 標准庫的許多其他實現不會表現出這種行為,或者程度較低。 這只是GCC開發人員很久以前做出的設計決定。 看起來他們現在正在減少這種行為,使其更符合其他實現。 這使您可以更好地控制包含的內容和不包含的內容。 舊代碼會中斷,但可以通過包含缺少的標頭輕松修復。

Apple論壇上的帖子暗示

#include <algorithm>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM