gcc4 warnings -Wuninitialized -Wfloat-equal and -Wconversion
Thiago Macieira
thiago at kde.org
Wed Sep 23 16:57:11 BST 2009
Em Quarta-feira 23 Setembro 2009, às 09:48:23, você escreveu:
> 2009/9/23 Thiago Macieira <thiago at kde.org>:
> > Em Terça-feira 22. Setembro 2009, às 22.18.08, Jaime Torres escreveu:
> >> using a struct like this:
> >>
> >> typedef enum {
> >> LeftToRight,
> >> RightToLeft
> >> } LayoutDirection_T;
> >>
> >> typedef struct
> >> {
> >> LayoutDirection_T b:1;
> >> }
> >> LayoutDirection;
> >>
> >> test2.cpp compiles cleanly.
> >
> > How do you plan on placing a value inside that struct?
> >
> > Are you going to define a constructor, like this?
> >
> > LayoutDirection(uint val) : b(val) {}
> >
> > Won't that generate the same warning?
>
> Good point.
> Let's assume then that it is done right (do not use -Wconversion)
> until the compiler generates the good warnings for the bitfields. But
> I'll use it from time to time to reduce the warnings in non bitfields.
Don't apply this change anywhere in public API. It breaks compatibility.
Also note that two structs with one bit of each, side-by-side, do not occupy
two bits in the same byte. In other words:
struct LayoutDirection
{ LayoutDirectionEnum b: 1; };
struct SomeOtherField
{ SomeOtherFieldEnum b: 1; };
struct Private1
{
LayoutDirectionEnum layout :1;
SomeOtherFieldEnum field : 1;
};
struct Private2
{
LayoutDirection layout;
SomeOtherField field;
};
sizeof(Private1) != sizeof(Private2)
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14 San Francisco, California: Nov 2 - 4
http://qt.nokia.com/qtdevdays2009
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090923/095e2552/attachment.sig>
More information about the kde-core-devel
mailing list