Ulr*_*nin 1 c++ qt struct c++11
再会,
我第一次出现这种错误。
// another.h
struct Item {
QString name = QString();
QString description = QString();
QVariant value = QVariant();
struct Interface {
uint id = 0;
uint pos = 0;
} mkio, uks;
struct Element {
float weight = 0;
struct Range {
uint from = 0;
uint to = 0;
} range;
int index = 0;
} element;
};
Run Code Online (Sandbox Code Playgroud)
我想将此嵌套结构存储在流中。所以,
// another.h
QDataStream &operator<<(QDataStream &out, const Item::Interface &interface)
{
return out << interface.id
<< interface.pos;
}
// and another overload operator>> and operator<<...
// Another fields of the `Item` struct are compiling without any error.
Run Code Online (Sandbox Code Playgroud)
1) 错误:在 'struct' QDataStream &operator<<(QDataStream &out, const Item::Interface &interface) 之前预期的 ',' 或 '...'
2)another.h:34:17:错误:'struct'
返回之前的预期主表达式<< interface.id
^
another.h:34:17:错误:预期';' 在“struct”
another.h:34:17 之前:错误:“struct”之前的预期主表达式
在代码中的某处,很可能在库头文件中,隐藏了以下(或与它非常相似的内容):
#define interface struct
Run Code Online (Sandbox Code Playgroud)
这使编译器看到:
QDataStream &operator<<(QDataStream &out, const Item::Interface &struct)
{
return out << struct.id
<< struct.pos;
}
Run Code Online (Sandbox Code Playgroud)
并变得非常沮丧。
重命名参数。
| 归档时间: |
|
| 查看次数: |
770 次 |
| 最近记录: |