【发布时间】:2016-04-29 12:14:34
【问题描述】:
我有一个在 GCC 5.3、MSVC12 和 clang 3.7 中编译良好的代码。但是,它在 MSVC14 中没有。它以某种方式尝试使用成员而不是命名空间,我真的不知道这里发生了什么。
#include <QtCore/qglobal.h>
namespace data
{
class Bar {};
}
struct Parent
{
int data;
};
namespace other
{
struct Foo : public Parent
{
void foo(data::Bar);
};
}
void other::Foo::foo(data::Bar) { }
int main()
{
return 0;
}
结果
cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zc:throwingNew -Zi -MDd -GR -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -EHsc /Fddebug\bug.pdb -DUNICODE -DWIN32 -DWIN64 -DQT_QML_DEBUG -DQT_CORE_LIB -I..\bug -I. -IE:\Qt\Qt5.6.0\5.6\msvc2015_64\include -IE:\Qt\Qt5.6.0\5.6\msvc2015_64\include\QtCore -Idebug -IE:\Qt\Qt5.6.0\5.6\msvc2015_64\mkspecs\win32-msvc2015
main.cpp
..\bug\main.cpp(21): error C2327: 'Parent::data': is not a type name, static, or enumerator
请注意,这是一个 Qt 项目,如果我删除包含,它可以编译。基本上,如果我更改此代码中的任何内容,它就可以编译。例如这有效:
namespace other
{
void Foo::foo(data::Bar) { }
}
如果我重命名成员变量数据或命名空间数据,它也可以工作。但是我无法在现实中进行这些更改,声明是由 qmake 生成的代码,重命名命名空间不是一种选择。
这可能是编译器错误吗?有什么想法吗?
【问题讨论】:
标签: c++ qt visual-c++ visual-studio-2015