IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

Erreur STL MAP


Sujet :

C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Janvier 2010
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 3
    Par défaut Erreur STL MAP
    Bonjour,

    J'ai une erreur a propos des map de la STL. Je pense avoir bien manipule les maps. Mais des que je fais #include <map> ca fait des erreur de compile. Meme si je n'utilise pas les map... Voici le code j'espere que vous saviez d'ou vient l'erreur.
    Os : Freebsd
    Compilo : g++


    ERROr :
    c++ -Wall -W -Werror -c main.cpp
    In file included from /usr/include/c++/3.4/map:67,
    from tree.hpp:8,
    from main.cpp:4:
    /usr/include/c++/3.4/bits/stl_map.h:121: error: expected `;' before '<' token
    /usr/include/c++/3.4/bits/stl_map.h:124: error: `_Rep_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:133: error: `_Rep_type' has not been declared
    /usr/include/c++/3.4/bits/stl_map.h:133: error: expected nested-name-specifier before "allocator_type"
    /usr/include/c++/3.4/bits/stl_map.h:133: error: `allocator_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:134: error: `_Rep_type' has not been declared
    /usr/include/c++/3.4/bits/stl_map.h:134: error: expected nested-name-specifier before "iterator"
    /usr/include/c++/3.4/bits/stl_map.h:134: error: `iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:135: error: `_Rep_type' has not been declared
    /usr/include/c++/3.4/bits/stl_map.h:135: error: expected nested-name-specifier before "const_iterator"
    /usr/include/c++/3.4/bits/stl_map.h:135: error: `const_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:136: error: `_Rep_type' has not been declared
    /usr/include/c++/3.4/bits/stl_map.h:136: error: expected nested-name-specifier before "size_type"
    /usr/include/c++/3.4/bits/stl_map.h:136: error: `size_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:137: error: `_Rep_type' has not been declared
    /usr/include/c++/3.4/bits/stl_map.h:137: error: expected nested-name-specifier before "difference_type"
    /usr/include/c++/3.4/bits/stl_map.h:137: error: `difference_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:138: error: `_Rep_type' has not been declared
    /usr/include/c++/3.4/bits/stl_map.h:138: error: expected nested-name-specifier before "reverse_iterator"
    /usr/include/c++/3.4/bits/stl_map.h:138: error: `reverse_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:139: error: `_Rep_type' has not been declared
    /usr/include/c++/3.4/bits/stl_map.h:139: error: expected nested-name-specifier before "const_reverse_iterator"
    /usr/include/c++/3.4/bits/stl_map.h:139: error: `const_reverse_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:155: error: expected `,' or `...' before '&' token
    /usr/include/c++/3.4/bits/stl_map.h:195: error: expected `,' or `...' before '&' token
    /usr/include/c++/3.4/bits/stl_map.h:223: error: `allocator_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:233: error: `iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:242: error: `const_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:250: error: `iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:259: error: `const_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:268: error: `reverse_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:277: error: `const_reverse_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:286: error: `reverse_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:295: error: `const_reverse_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:308: error: `size_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:313: error: `size_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:359: error: type/value mismatch at argument 1 in template parameter list for `template<class _T1, class _T2> struct std::pair'
    /usr/include/c++/3.4/bits/stl_map.h:359: error: expected a type, got `iterator'
    /usr/include/c++/3.4/bits/stl_map.h:382: error: `iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:409: error: variable or field `erase' declared void
    /usr/include/c++/3.4/bits/stl_map.h:409: error: expected `;' before '(' token
    /usr/include/c++/3.4/bits/stl_map.h:423: error: expected `;' before "size_type"
    /usr/include/c++/3.4/bits/stl_map.h:423: error: `size_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:439: error: variable or field `erase' declared void
    /usr/include/c++/3.4/bits/stl_map.h:439: error: expected `;' before '(' token
    /usr/include/c++/3.4/bits/stl_map.h:453: error: expected `;' before "void"
    /usr/include/c++/3.4/bits/stl_map.h:496: error: `iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:511: error: `const_iterator' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:523: error: `size_type' does not name a type
    /usr/include/c++/3.4/bits/stl_map.h:538: error: `iterator' does not name a type

    main.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    #include <string>
    #include <iostream>
    #include "loadFile.hpp"
    #include "tree.hpp"
     
    int     main(int argc, char *argv[])
    {
      if (argc < 3)
        {
          std::cout << "Bad format !" << std::endl;
          return (EXIT_FAILURE);
        }
      loadDataFromFile *data = new loadDataFromFile(argv[1]);
      if (data->load())
        {
          // data->dumpData();                                                                                                                                                                                                                                                     
          Tree T;
          T.buildTree(data->getData());
        }
      else
        {
          std::cout << "Could not get data from file" << std::endl;
          return (EXIT_FAILURE);
        }
      delete data;
      return (EXIT_SUCCESS);
    }
    tree.hpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
     
    #ifndef _TREE_H
    #define _TREE_H
     
    #include <iostream>
    #include <string>
    #include <vector>
    #include <list>
    #include <map>
     
    class Tree
    {
    public :
      Tree();
      ~Tree();
     
      void  buildTree(std::vector<std::string>&);
      void  stringtok(std::string&, std::vector<std::string>&, std::string&);
     
    private :
      std::map<int, std::list<double> >     _tree;
      int                                   _nb_states;
    };
     
    #endif //_TREE_H
    tree.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
     
    #include <iostream>
    #include <string>
    #include <vector>
    #include <list>
    #include <map>
    #include <fstream>
    #include "tree.hpp"
     
     
    Tree::Tree()
    {
    }
     
    Tree::~Tree()
    {
    }
     
    void Tree::stringtok(std::string& str, std::vector<std::string> &tokens, std::string& delimiters)
    {
      std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
      std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
     
      while (std::string::npos != pos || std::string::npos != lastPos)
        {
          tokens.push_back(str.substr(lastPos, pos - lastPos));
          lastPos = str.find_first_not_of(delimiters, pos);
          pos = str.find_first_of(delimiters, lastPos);
        }
    }
     
    void    Tree::buildTree(std::vector<std::string>& line)
    {
      std::vector<std::string>::iterator it;
     
      it = line.begin();
      this->_nb_states = atoi((*it).c_str());
      ++it;
      for (int i = 0; i < this->_nb_states; i++)
        {
          std::vector<std::string> listnode;
          std::string del(" ");
          this->stringtok((*it), listnode, del);
          std::list<double> tmp;
     
          for (int j = 0; j < this->_nb_states; j++)
            tmp.push_back(atof(listnode[j]));
          this->_tree[i] = tmp;
          ++it;
        }
    loadfile.hpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    #ifndef _LOADFILE_H
    #define _LOADFILE_H
     
    #include <iostream>
    #include <string>
    #include <vector>
    #include <fstream>
     
    class loadDataFromFile
    {
    public :
      loadDataFromFile(std::string);
      ~loadDataFromFile();
      bool  openFile();
      void  closeFile();
      std::vector<std::string>&     getData();
      void  loadData();
      void  dumpData();
      bool  load();
     
    private :
      std::string                   _path;
      std::vector<std::string>      _lines;
      std::ifstream                 _fd;
    };
     
    #endif //_LOADFILE_H

  2. #2
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Bonjour et bienvenu,
    Dev-c++ n'est plus maintenu et probablement obsolète. Je te conseille de te tourner vers un autre I.D.E. (par expl, Code::block+gcc). Tu trouveras une liste des outils dispo sur la page dédiée.

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Janvier 2010
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 3
    Par défaut
    Je ne suis pas sur dev-c++ je suis sous unix et je compile avec g++.

  4. #4
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Salut,
    Comme t'avais posté dans Dev-cpp, j'avais cru. Dsl.

    A quoi ressemble loadFile.hpp ?

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Janvier 2010
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 3
    Par défaut
    Voila jai mi loadfile.hpp

    Merci.

  6. #6
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Je vois pas de choses trop bizarres. Si tu créés un projet vide avec juste un include de <map>, tu as le même problème ? Ce serait peut être un problème d'installation du compilo ?

Discussions similaires

  1. Erreur de mapping hibernate 2 avec eclipse
    Par khamed dans le forum Hibernate
    Réponses: 11
    Dernier message: 11/01/2008, 14h26
  2. [DEBUTANT] many-to-one erreur de mapping ?!
    Par zybay dans le forum Hibernate
    Réponses: 7
    Dernier message: 14/05/2007, 14h56
  3. inserer dans stl::map
    Par ocean24 dans le forum SL & STL
    Réponses: 4
    Dernier message: 23/04/2007, 01h47
  4. STL map const et une erreur dans une condition...
    Par insomniak dans le forum SL & STL
    Réponses: 2
    Dernier message: 15/05/2006, 17h56
  5. STL, map et operateur '+'
    Par insomniak dans le forum SL & STL
    Réponses: 25
    Dernier message: 13/05/2006, 18h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo