C2143, hash_map

Discussion in 'C++' started by Florian Liefers, Nov 12, 2003.

  1. "Hello World\n",

    i get error C2143 (Syntaxerror, missing ';' before '<') using the
    following code:

    #include <hash_map>

    struct eqstr
    {
    bool operator()(const char* s1, const char* s2) const
    {
    return strcmp(s1, s2) == 0;
    }
    };

    typedef hash_map<const char*, int, hash<const char*>, eqstr> months;

    hope anyone can help me!

    Tnx,
    Florian
     
    Florian Liefers, Nov 12, 2003
    #1
    1. Advertising

  2. "Florian Liefers" <> wrote...
    > "Hello World\n",
    >
    > i get error C2143 (Syntaxerror, missing ';' before '<') using the
    > following code:
    >
    > #include <hash_map>
    >
    > struct eqstr
    > {
    > bool operator()(const char* s1, const char* s2) const
    > {
    > return strcmp(s1, s2) == 0;
    > }
    > };
    >
    > typedef hash_map<const char*, int, hash<const char*>, eqstr> months;


    What's "hash_map"? Are you sure it's the name of the template?
    Are you sure it's not in some kind of namespace that you forgot
    to mention?

    The questions and doubts expressed by me here are due to the fact
    that there is no standard header <hash_map>, so you cannot assume
    that anybody here knows what you're talking about.

    Victor
     
    Victor Bazarov, Nov 12, 2003
    #2
    1. Advertising

  3. "Hello World\n",

    > What's "hash_map"? Are you sure it's the name of the template?
    > Are you sure it's not in some kind of namespace that you forgot
    > to mention?
    >
    > The questions and doubts expressed by me here are due to the fact
    > that there is no standard header <hash_map>, so you cannot assume
    > that anybody here knows what you're talking about.


    I found hash_map here:
    http://www.sgi.com/tech/stl/hash_map.html
    I can open the header file hash_map and in VC.NET there is a help site by
    pressing F1.

    If there is another hash-map class please tell me! That would be very
    nice!!!

    Tnx,
    Florian
     
    Florian Liefers, Nov 12, 2003
    #3
  4. "Florian Liefers" <> wrote...
    > "Hello World\n",
    >
    > > What's "hash_map"? Are you sure it's the name of the template?
    > > Are you sure it's not in some kind of namespace that you forgot
    > > to mention?
    > >
    > > The questions and doubts expressed by me here are due to the fact
    > > that there is no standard header <hash_map>, so you cannot assume
    > > that anybody here knows what you're talking about.

    >
    > I found hash_map here:
    > http://www.sgi.com/tech/stl/hash_map.html
    > I can open the header file hash_map and in VC.NET there is a help site by
    > pressing F1.


    That's all nice, but it has nothing to do with Standard C++. If you
    read carefully, you can see that on SGI's web page it says that the
    hash_map is an extension, not part of the standard C++. Whatever VC++
    tells you is also beyond the scope of this newsgroup. Could it be
    that the two hash_map implementations get confused by your VC++ compiler?

    > If there is another hash-map class please tell me! That would be very
    > nice!!!


    There probably is. But why don't you use 'std::map' instead? It
    works fine for what you need (probably), and it would be topical
    here.

    Victor
     
    Victor Bazarov, Nov 12, 2003
    #4
  5. Florian Liefers

    Ali R. Guest

    "Florian Liefers" <> wrote in message
    news:eek:...
    > "Hello World\n",
    >
    > i get error C2143 (Syntaxerror, missing ';' before '<') using the
    > following code:
    >
    > #include <hash_map>
    >
    > struct eqstr
    > {
    > bool operator()(const char* s1, const char* s2) const
    > {
    > return strcmp(s1, s2) == 0;
    > }
    > };
    >
    > typedef hash_map<const char*, int, hash<const char*>, eqstr> months;

    ^^^^
    what is hash defined as?

    Ali R.
     
    Ali R., Nov 12, 2003
    #5
  6. "Hello World\n",
    >> typedef hash_map<const char*, int, hash<const char*>, eqstr> months;

    > ^^^^
    > what is hash defined as?

    Hm, good question. But in the doc params >2 are optional.
    I also tried it just with 2 params (without hash<const char*>, eqstr), but
    the same error occurs :-(.

    I found hashmap @ http://www.sgi.com/tech/stl/hash_map.html

    Florian
     
    Florian Liefers, Nov 12, 2003
    #6
  7. > That's all nice, but it has nothing to do with Standard C++. If you
    > read carefully, you can see that on SGI's web page it says that the
    > hash_map is an extension, not part of the standard C++. Whatever VC++
    > tells you is also beyond the scope of this newsgroup. Could it be
    > that the two hash_map implementations get confused by your VC++ compiler?

    Ok, sorry for OT, i didn't know.

    > There probably is. But why don't you use 'std::map' instead? It
    > works fine for what you need (probably), and it would be topical
    > here.

    Yes, that's exactly what i'm searching for. The problem is, that now i get
    the same error with map :-(

    #include <map>
    typedef map<int, char *> alienMap;

    results in
    error C2143: Syntaxfehler : Es fehlt ';' vor '<'
    which means in english: missing ';' before '<'

    Florian
     
    Florian Liefers, Nov 12, 2003
    #7
  8. Florian Liefers escribió:

    > #include <map>
    > typedef map<int, char *> alienMap;
    >
    > results in
    > error C2143: Syntaxfehler : Es fehlt ';' vor '<'
    > which means in english: missing ';' before '<'



    typedef std::map<int, char *> alienMap;

    Or put "using std::map;" after the #include.

    Regards.
     
    =?iso-8859-1?Q?Juli=E1n?= Albo, Nov 12, 2003
    #8
  9. "Florian Liefers" <> wrote...
    > > That's all nice, but it has nothing to do with Standard C++. If you
    > > read carefully, you can see that on SGI's web page it says that the
    > > hash_map is an extension, not part of the standard C++. Whatever VC++
    > > tells you is also beyond the scope of this newsgroup. Could it be
    > > that the two hash_map implementations get confused by your VC++

    compiler?
    > Ok, sorry for OT, i didn't know.
    >
    > > There probably is. But why don't you use 'std::map' instead? It
    > > works fine for what you need (probably), and it would be topical
    > > here.

    > Yes, that's exactly what i'm searching for. The problem is, that now i get
    > the same error with map :-(
    >
    > #include <map>
    > typedef map<int, char *> alienMap;
    >
    > results in
    > error C2143: Syntaxfehler : Es fehlt ';' vor '<'
    > which means in english: missing ';' before '<'


    In the header <map> the template 'map' is declared in 'std' namespace.
    You HAVE TO tell your compiler that you're going to be using the 'map'
    from 'std':

    typedef std::map<int,char*> alienMap;

    Victor
     
    Victor Bazarov, Nov 12, 2003
    #9
  10. >> #include <map>
    >> typedef map<int, char *> alienMap;
    >>
    >> results in
    >> error C2143: Syntaxfehler : Es fehlt ';' vor '<'
    >> which means in english: missing ';' before '<'

    >
    > In the header <map> the template 'map' is declared in 'std' namespace.
    > You HAVE TO tell your compiler that you're going to be using the 'map'
    > from 'std':
    >
    > typedef std::map<int,char*> alienMap;


    Oh no, just like a beginner... (me)

    That's it...Thanks alot!!!!!!!!!!!!

    Florian
     
    Florian Liefers, Nov 12, 2003
    #10

  11. >> #include <map>
    >> typedef map<int, char *> alienMap;
    >> error C2143: Syntaxfehler : Es fehlt ';' vor '<'

    > typedef std::map<int, char *> alienMap;
    > Or put "using std::map;" after the #include.


    That's it, thank you!!!

    Florian
     
    Florian Liefers, Nov 12, 2003
    #11
  12. Florian Liefers

    Dan Cernat Guest

    Florian Liefers <> wrote in message news:<>...
    > "Hello World\n",
    >
    > i get error C2143 (Syntaxerror, missing ';' before '<') using the
    > following code:
    >
    > #include <hash_map>
    >
    > struct eqstr
    > {
    > bool operator()(const char* s1, const char* s2) const
    > {
    > return strcmp(s1, s2) == 0;
    > }
    > };
    >
    > typedef hash_map<const char*, int, hash<const char*>, eqstr> months;

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^6
    I suspect the problem is with hash<const char*>
    probably your compiler doesn't know who is 'hash' which is right
    before the '<' sign.
    >
    > hope anyone can help me!
    >
    > Tnx,
    > Florian


    HTH
    /dan
     
    Dan Cernat, Nov 12, 2003
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kristofer Pettijohn

    2d hash_map iteration ?

    Kristofer Pettijohn, Jun 26, 2003, in forum: C++
    Replies:
    1
    Views:
    995
    Rob Williscroft
    Jun 26, 2003
  2. Jacek Generowicz

    Pre-standardizing hash_map & friends.

    Jacek Generowicz, Aug 26, 2003, in forum: C++
    Replies:
    0
    Views:
    362
    Jacek Generowicz
    Aug 26, 2003
  3. Rhodrey

    Error C2143

    Rhodrey, Sep 21, 2003, in forum: C++
    Replies:
    2
    Views:
    2,891
    Peter Kragh
    Sep 21, 2003
  4. Charles Herman

    hash_map iterator

    Charles Herman, Nov 3, 2003, in forum: C++
    Replies:
    5
    Views:
    5,993
    Ron Natalie
    Nov 4, 2003
  5. Replies:
    2
    Views:
    27,742
    Chris Jefferson
    Dec 14, 2004
Loading...

Share This Page