2011-06-15 126 views
0

我有一段代碼,使用升壓轉換器的unordered_set升壓/ unordered_set:編譯MinGW的錯誤()

#include <boost/unordered_set.hpp> 
boost::unordered_set<string> mySet(100); 

它編譯和正常工作與UNIX下的gcc。當我嘗試用交叉編譯的mingw32(GMAKE 3.8.1)我得到以下信息:

In file included 
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/functional/hash/detail/hash_float.hpp:17, 
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/functional/hash/hash.hpp:15, 
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/functional/hash.hpp:6, 
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/unordered/unordered_set.hpp:17, 
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/unordered_set.hpp:16, 
from /mnt/VirtualBoxShare/percolator/src/ProteinProbEstimatorHelper.h:33, 
from /mnt/VirtualBoxShare/percolator/src/ProteinProbEstimator.cpp:28: 

/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:105: error: expected unqualified-id before 'unsigned' 
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:105: error: expected ';' before 'unsigned' 
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:105: error: declaration does not declare anything 
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:114: error: expected unqualified-id before 'unsigned' 
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:114: error: expected ';' before 'unsigned' 
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:114: error: declaration does not declare anything 

對我來說,這似乎是一個與模板有關的問題;有什麼建議麼?

謝謝 馬蒂亞


[編輯]

其他升壓功能是可用的,例如詞彙投

#include <boost/lexical_cast.hpp> 
+0

MinGW和gcc的哪個版本?也許你可以使用C++ 0x unordered_set來代替這個來自boost的? – Zuljin 2011-06-15 15:02:45

+0

什麼版本的Boost?你有'#包括'?和'使用std :: string;'或'使用namespace std;'? – ildjarn 2011-06-15 18:56:21

+0

@Zuljin對不起,mingw32-boost-1.41.0和mingw32-gcc-C++ - 4.4.2。包含字符串標題,我使用std :: string。 – 2011-06-16 12:01:22

回答

1

這似乎有些類型定義打破了升壓cstdint頭看起來像

103 using ::int8_t; 
104 using ::int_least8_t; 
105 using ::int_fast8_t; 
106 using ::uint8_t; 
107 using ::uint_least8_t; 
108 using ::uint_fast8_t; 

在我的系統上。所以,一些英雄可能定義了「#define uint8_t」而不是「typedef ... uint8_t」,並且這個代碼因此而中斷。

你可能會嘗試修改你的boost/config/platform/win32.hpp,如果有幫助的話,向bug開發人員報告bug。

+0

你說的很對。我在我的項目中發現有一個「英雄」做了同樣的事情:''#define uint8_t unsigned char'' – Krypton 2014-08-18 06:33:01