QT/mingw-结构中的结构
我有下面的c程序,它在VisualStudio下编译,但在Qt5.2中失败QT/mingw-结构中的结构,qt,Qt,我有下面的c程序,它在VisualStudio下编译,但在Qt5.2中失败 #include <stdio.h> struct structA { int x; struct structB { int d; } y; }; int main(int argc, char *argv[]) { struct structA ad; struct structB ab; return 0; } 你知道为什么这
#include <stdio.h>
struct structA
{
int x;
struct structB
{
int d;
} y;
};
int main(int argc, char *argv[])
{
struct structA ad;
struct structB ab;
return 0;
}
你知道为什么这在Visual Studio中有效而不是在QT中吗?当我将代码粘贴到一个文件中,并使用GCC(与MinGW大致相同的工具链)在Mac上编译它时,我得到了你报告的错误。我可以通过如下更改代码来消除错误:
#include <stdio.h>
struct structA
{
int x;
struct structB
{
int d;
} y;
};
int main(int argc, char *argv[])
{
struct structA ad;
// Tell the compiler where to find structB
struct structA::structB ab;
return 0;
}
在Windows上,我必须做同样的更改才能编译它。您确定两种情况下的代码相同吗?可能没有Visual Studio帮助添加的“使用”或其他作用域操作符?是
c
编译器还是c++
编译器?
#include <stdio.h>
struct structA
{
int x;
struct structB
{
int d;
} y;
};
int main(int argc, char *argv[])
{
struct structA ad;
// Tell the compiler where to find structB
struct structA::structB ab;
return 0;
}
C:\Users\sarah_000\depot\structs\main.cpp:15: error: C2079: 'ab' uses undefined struct 'main::structB'