problems switching to gcc 3.3.2

  • Thread starter Christian Christmann
  • Start date
C

Christian Christmann

Hi,

compiling my source files with gcc 2.95.3 works fine.
When I switch to gcc 3.3.2 and try to compile the same
files I get some error messages.

My header file hash.h begins with:

#include <map>
#include <string>
[snip]
class HashTable
{
map<int, void*> nhash; //line 49
map<string, void*> shash; //line 50
[snip]

Trying to compile I get:
In file included from hash.cpp:8:
hash.h:49: error: 'map' is used as a type, but is not defined as a type.
hash.h:50: error: `string' was not declared in this scope
hash.h:50: error: 'map' is used as a type, but is not defined as a type.


Any ideas how to solve that problem.

Chris
 
V

Victor Bazarov

Christian said:
compiling my source files with gcc 2.95.3 works fine.
When I switch to gcc 3.3.2 and try to compile the same
files I get some error messages.

My header file hash.h begins with:

#include <map>
#include <string>
[snip]
class HashTable
{
map<int, void*> nhash; //line 49
map<string, void*> shash; //line 50
[snip]

Trying to compile I get:
In file included from hash.cpp:8:
hash.h:49: error: 'map' is used as a type, but is not defined as a type.
hash.h:50: error: `string' was not declared in this scope
hash.h:50: error: 'map' is used as a type, but is not defined as a type.


Any ideas how to solve that problem.

Have you tried

std::map<int,void*> nhash;
std::map<std::string,void*> shash;

or at least

using std::map;
using std::string;

or if all else fails

using namespace std;

?

V
 
C

Christian Christmann

#include <map>
#include <string>
[snip]
class HashTable
{
map<int, void*> nhash; //line 49
map<string, void*> shash; //line 50
[snip]

Trying to compile I get:
In file included from hash.cpp:8:
hash.h:49: error: 'map' is used as a type, but is not defined as a type.
hash.h:50: error: `string' was not declared in this scope hash.h:50:
error: 'map' is used as a type, but is not defined as a type.
Have you tried

std::map<int,void*> nhash;
std::map<std::string,void*> shash;

Thanks, it works

Chris
 
I

Ioannis Vranos

Christian said:
#include <map>
#include <string>
[snip]
class HashTable
{
map<int, void*> nhash; //line 49
map<string, void*> shash; //line 50
[snip]

Trying to compile I get:
In file included from hash.cpp:8:
hash.h:49: error: 'map' is used as a type, but is not defined as a type.
hash.h:50: error: `string' was not declared in this scope
hash.h:50: error: 'map' is used as a type, but is not defined as a type.


Any ideas how to solve that problem.


using namespace std;
 
H

Howard

Ioannis Vranos said:
Christian said:
#include <map>
#include <string>
[snip]
class HashTable
{
map<int, void*> nhash; //line 49
map<string, void*> shash; //line 50
[snip]

Trying to compile I get:
In file included from hash.cpp:8:
hash.h:49: error: 'map' is used as a type, but is not defined as a type.
hash.h:50: error: `string' was not declared in this scope
hash.h:50: error: 'map' is used as a type, but is not defined as a type.


Any ideas how to solve that problem.


using namespace std;

Not a good idea, since this is in a header file. Better to juse qualify the
map and string types with std::.

-Howard
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top