Don't use an extension to the C++ language in public headers

According to Clang 3.3, this is an extension:
qpalette.h:178:9: error: anonymous types declared in an anonymous union are an extension [-Werror,-Wnested-anon-types]
qsizepolicy.h:148:9: error: anonymous types declared in an anonymous union are an extension [-Werror,-Wnested-anon-types]

If you try to simply give the struct a name, it complains with:
qpalette.h:178:16: error: types cannot be declared in an anonymous union

Change-Id: I61c69b8e42a1f4c4a15a0733f2d7efa0b3e44864
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
bb10
Thiago Macieira 2013-09-04 23:18:47 -07:00 committed by The Qt Project
parent c1c715f800
commit aef44c7970
2 changed files with 16 additions and 14 deletions

View File

@ -174,11 +174,12 @@ private:
void detach();
QPalettePrivate *d;
struct Data {
uint current_group : 4;
uint resolve_mask : 28;
};
union {
struct {
uint current_group : 4;
uint resolve_mask : 28;
} data;
Data data;
quint32 for_faster_swapping_dont_use;
};
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);

View File

@ -144,17 +144,18 @@ private:
#endif
QSizePolicy(int i) : data(i) { }
struct Bits {
quint32 horStretch : 8;
quint32 verStretch : 8;
quint32 horPolicy : 4;
quint32 verPolicy : 4;
quint32 ctype : 5;
quint32 hfw : 1;
quint32 wfh : 1;
quint32 retainSizeWhenHidden : 1;
};
union {
struct {
quint32 horStretch : 8;
quint32 verStretch : 8;
quint32 horPolicy : 4;
quint32 verPolicy : 4;
quint32 ctype : 5;
quint32 hfw : 1;
quint32 wfh : 1;
quint32 retainSizeWhenHidden : 1;
} bits;
Bits bits;
quint32 data;
};
};