2011-06-15 5 views
0

J'ai un morceau de code qui utilise unordered_set de boostboost/unordered_set: erreur de compilation avec MinGW()

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

Il compile et fonctionne très bien avec gcc sous unix. Lorsque je tente la compilation croisée avec mingw32 (gmake 3.8.1) Je reçois le message suivant:

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 

Pour moi, il semble comme un problème lié au modèle; Aucune suggestion?

Merci, Mattia


[EDIT]

autres fonctionnalités de boost sont disponibles, par exemple la distribution lexical

#include <boost/lexical_cast.hpp> 
+0

Quelle version de MinGW et gcc? Peut-être que vous pourriez utiliser C++ 0x unordered_set au lieu de celui-ci de boost? – Zuljin

+0

Quelle version de Boost? Avez-vous '#include '? Et 'using std :: string;' ou 'using namespace std;'? – ildjarn

+0

@Zuljin désolé, mingw32-boost-1.41.0 et mingw32-gcc-C++ - 4.4.2. L'en-tête de chaîne est inclus et j'utilise std :: string. –

Répondre

1

Il semble que certains typedef brise la cstdint boost en-tête, qui ressemble à

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; 

sur mon système. Donc, certains héros ont probablement défini "#define uint8_t" au lieu de "typedef ... uint8_t", et ce code est donc cassé.

Vous pouvez essayer de modifier votre fichier boost/config/platform/win32.hpp et, si cela vous aide, signaler le bug aux développeurs mingw.

+0

Vous avez tellement raison à ce sujet. J'ai trouvé dans mon projet un "héros" qui a fait la même chose: "#define uint8_t unsigned char'' – Krypton

Questions connexes