Aftershock
Aftershock

Reputation: 5351

forward declaration compiler error in a struct in C++

This compiles in Visual C++ 2010.

It does not compile und MINGW.

struct nextifcondinfo
{
  hash_map <string, nextifcondinfo> next;
  int action; 
};

I get an error message:
Description Resource    Path    Location    Type
forward declaration of 'struct nextifcondinfo'      C/C++ Problem

Can you tell me what switches to use in mingw to solve? Or do you have any other ideas?

Upvotes: 0

Views: 439

Answers (1)

jahhaj
jahhaj

Reputation: 3119

I don't believe your code is supposed to compile but it does depend on the hash_map implementation. Looks like you've been lucky with VC++ and unlucky with MinGW.

To solve use pointers, for instance

struct nextifcondinfo
{
  hash_map <string, nextifcondinfo*> next;
  int action; 
};

You could use smart pointers as well.

Upvotes: 5

Related Questions