2012-08-04 77 views
0

这个在Visual C++ 2010中编译。C++中的一个结构体中的前向声明编译器错误

它不编译和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 

你能告诉我在mingw中用什么开关来解决吗?或者你有其他想法吗?

+0

可能只是编译器的一个缺陷,在这种情况下,没有开关可以帮助:( – YePhIcK 2012-08-04 10:49:56

+0

什么是hash_map? – ForEveR 2012-08-04 10:52:30

+0

散列图是一个类似于数组的结构,其中有一个元素用于一个键key1-> element1和key2 - > element2类似的东西。通常用于快速(和恒定时间)访问元素 – 2012-08-04 10:53:39

回答

5

我不相信你的代码应该编译,但它取决于hash_map实现。看起来你用VC++很幸运,并且不喜欢MinGW。

为了解决使用指针,例如

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

您可以使用智能指针为好。