473,803 Members | 3,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C2143, hash_map

"Hello World\n",

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

#include <hash_map>

struct eqstr
{
bool operator()(cons t 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
Jul 19 '05 #1
11 9988
"Florian Liefers" <re*****@web.de > wrote...
"Hello World\n",

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

#include <hash_map>

struct eqstr
{
bool operator()(cons t 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
Jul 19 '05 #2
"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
Jul 19 '05 #3
"Florian Liefers" <re*****@web.de > 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
Jul 19 '05 #4
"Florian Liefers" <re*****@web.de > wrote in message
news:op******** ******@news.btx .dtag.de...
"Hello World\n",

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

#include <hash_map>

struct eqstr
{
bool operator()(cons t 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.

Jul 19 '05 #5
"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
Jul 19 '05 #6
> 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
Jul 19 '05 #7
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.
Jul 19 '05 #8
"Florian Liefers" <re*****@web.de > 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,ch ar*> alienMap;

Victor
Jul 19 '05 #9
>> #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,ch ar*> alienMap;


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

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

Florian
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
4764
by: Jon Cosby | last post by:
I need help in hashmaps. Why doesn't this work: #include <hash_map> hash_map <int, string> hm1; typedef pair <int, string> pr; hm1.insert(str_pair(1, "Hello")); It compiles, but crashes at runtime, pointing to something in xhash.
3
11881
by: Mark | last post by:
Hi, I'm trying to use hash_map (gcc 3.2.2) with a std::string as the key. It will compile if I use <map> but I get a bunch of template compile errors when I change it to hash_map. Any suggestions? My program and the errors are below... #include <ext/hash_map> #include <string>
5
8626
by: peter_k | last post by:
Hi I've defined hash_map in my code using this: ------------------------------------------- #include <string> #include <hash_map.h> & namespace __gnu_cxx {
3
3844
by: kony | last post by:
Hi there, I would much appreciate your help with the following problem. Below is the code that uses a hash_map. I want to release all the memory occupied by the hash_map for other use. Apparently clear() function is not working and the trick with swap() is half working. Does anybody know how to deallocate the hash_map? Thanks in advance. Kon #include <functional>
1
9404
by: jayesah | last post by:
Hi All, I am developing my code with Apache stdcxx. I am bound to use STL of Apache only. Now today I need hash_map in code but as I learned, it is not available in Apache since it is not standard c++. Though it is available with GNU STL. The code module where I use hash_map will generate separate object file during compilation. This code module is also using STL string.
2
4284
by: Amit Bhatia | last post by:
Hi, I am trying to use hash maps from STL on gcc 3.3 as follows: #ifndef NODE_H #define NODE_H #include <ext/hash_map> #include "node_hasher.h" class Node; typedef hash_map<pair<int,int>, Node, Node_HasherLoc_Tree;
4
3417
by: James Kanze | last post by:
On Jul 16, 10:53 pm, Mirco Wahab <wa...@chemie.uni-halle.dewrote: It depends. You might like to have a look at my "Hashing.hh" header (in the code at kanze.james.neuf.fr/code-en.html---the Hashing component is in the Basic section). Or for a discussion and some benchmarks, http://kanze.james.neuf.fr/code/Docs/html/Hashcode.html. (That article is a little out of date now, as I've tried quite a few more hashing algorithms. But the...
5
3376
by: frankw | last post by:
Hi, I have a hash_map with string as key and an object pointer as value. the object is like class{ public: float a; float b; ...
2
8152
by: marek.vondrak | last post by:
Hi, I am wondering if there are any functional differences between SGI's hash_map and tr1's unordered_map. Can these two containers be interchanged? What would it take to switch from hash_map to unordered_map? Thank you. -Marek
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.