C++中结构中的前向声明编译器错误

Aft*_*ock 0 c++ mingw visual-studio-2010

这在Visual C++ 2010中编译.

它不编译和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
Run Code Online (Sandbox Code Playgroud)

你能告诉我在mingw中使用哪些开关来解决?或者你还有其他想法吗?

jah*_*haj 5

我不相信你的代码应该编译,但它确实依赖于hash_map实现.看起来你很幸运VC++而且不幸的是MinGW.

例如,要解决使用指针

struct nextifcondinfo
{
  hash_map <string, nextifcondinfo*> next;
  int action; 
};
Run Code Online (Sandbox Code Playgroud)

你也可以使用智能指针.