Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C+;中的结构中的前向声明编译器错误+;_C++_Visual Studio 2010_Mingw - Fatal编程技术网

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

C++ C+;中的结构中的前向声明编译器错误+;,c++,visual-studio-2010,mingw,C++,Visual Studio 2010,Mingw,这是在Visual C++ 2010中编译的。 它不编译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'

这是在Visual C++ 2010中编译的。 它不编译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
struct nextifcondinfo
{
下一步是hash_映射;
内联作用;
};
我收到一条错误消息:
说明资源路径位置类型
“struct nextifcondinfo”C/C++问题的转发声明

你能告诉我在mingw中使用什么开关来解决这个问题吗?或者您还有其他想法吗?

我不认为您的代码应该编译,但它确实取决于哈希映射的实现。看起来你在VC++上很幸运,而在MinGW上很不幸

例如,要解决此问题,请使用指针

struct nextifcondinfo
{
  hash_map <string, nextifcondinfo*> next;
  int action; 
};
struct nextifcondinfo
{
下一步是hash_映射;
内联作用;
};

您也可以使用智能指针。

我不认为您的代码应该编译,但它确实取决于哈希映射的实现。看起来你在VC++上很幸运,而在MinGW上很不幸

例如,要解决此问题,请使用指针

struct nextifcondinfo
{
  hash_map <string, nextifcondinfo*> next;
  int action; 
};
struct nextifcondinfo
{
下一步是hash_映射;
内联作用;
};

您也可以使用智能指针。

可能只是编译器的一个缺陷,在这种情况下,没有开关会有帮助:(哈希映射是一种类似数组的结构,其中一个键有一个元素。key1->element1和key2->element2类似。通常用于快速(和恒定时间)访问元素这不是一个缺陷。当结构用作模板参数时,它仍然是一个不完整的类型。这只是偶然的,它有时在某些编译器中也能正常工作。@BoPersson,我不会说这是“偶然的”.事实上,C++11在允许它使用编写良好的代码方面更灵活一些,一个符合C++11标准的编译器应该可以使用它。@Aaron-引用该链接“在以下情况下效果是未定义的:(…)-特别是-如果类型不完整(3.9)在实例化模板组件时用作模板参数,除非该组件特别允许。我不认为它特别允许用于
hash\u map
。这可能只是编译器的一个缺陷,在这种情况下,没有开关会有帮助:(哈希映射是一种类似数组的结构,其中一个键对应一个元素。key1->element1和key2->element2类似于此。通常用于快速(和恒定时间)访问元素这不是一个缺陷。当结构用作模板参数时,它仍然是一个不完整的类型。这只是偶然的,它有时在某些编译器中也能正常工作。@BoPersson,我不会说它是“偶然的”“。事实上,C++11更灵活地允许它使用编写良好的代码,一个合格的C++11编译器应该可以使用它。@Aaron-引用该链接“在以下情况下效果是未定义的:(…)特别是-如果类型不完整(3.9)在实例化模板组件时用作模板参数,除非该组件特别允许”。我不认为它特别允许用于
hash\u map