[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cannot compile hash_map from stlport

From: Jim Anderson
Subject: cannot compile hash_map from stlport
Date: Wed, 07 Nov 2007 03:40:26 GMT
User-agent: Thunderbird (X11/20070824)

I'd like to use the hash_map template from the stlport which I
picked up at (version 5.1.4). I installed the
library and then create the example given at I've attached
this example ( and a simple makefile. The only change I've
made to the example is to add the #include statements
for iostream and hash_map.

When I compile, I get the following output:

g++ -I/home/jja/work/prog/dev/ind/include/stlport -o sample In function ‘int main()’: error: ‘hash_map’ was not declared in this scope error: expected primary-expression before ‘const’ error: expected `;' before ‘const’ error: ‘months’ was not declared in this scope error: ‘cout’ was not declared in this scope error: ‘endl’ was not declared in this scope
make: *** [sample] Error 1

I ran the sample program through cpp to verify that hash_map
is being read in. It appears to be read in, yet I'm getting
the error that 'hash_map' was not declared. I'm guessing
the error message is telling me that the template is not
instansiating the hash_map class that is needed, but I'm
not sure. Can anyone explain the error message and why
the SGI example will not compile?

Jim Anderson

#include <iostream>
#include "hash_map.h"

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

int main()
  hash_map<const char*, int, hash<const char*>, eqstr> months;
  months["january"] = 31;
  months["february"] = 28;
  months["march"] = 31;
  months["april"] = 30;
  months["may"] = 31;
  months["june"] = 30;
  months["july"] = 31;
  months["august"] = 31;
  months["september"] = 30;
  months["october"] = 31;
  months["november"] = 30;
  months["december"] = 31;
  cout << "september -> " << months["september"] << endl;
  cout << "april     -> " << months["april"] << endl;
  cout << "june      -> " << months["june"] << endl;
  cout << "november  -> " << months["november"] << endl;

        g++ -I/home/jja/work/prog/dev/ind/include/stlport -o sample
#       cpp -I/home/jja/work/prog/dev/ind/include/stlport -o sample

reply via email to

[Prev in Thread] Current Thread [Next in Thread]