[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Fri Jul 10 12:21:51 CEST 2015


Il 10/07/2015 12:12, Curtis Mitch ha scritto:
> How is it binary incompatible?

Because the code produced by QList<C> (which is inlined) is incompatible 
if C becomes a "good" type (from a "bad" one) or viceversa.

The code for a "bad" C involves allocating every C object on the heap, 
putting the pointer in the backing array, and dereferencing that pointer 
to get the C back; the code for a "good" C involves putting and 
retrieving C straight into/from the backing array.

What happens if you have a library which creates a QList<C> assuming C 
to be "bad", and then passes that QList<C> to your app, which assumes C 
to be "good"? This is what happens if you add a typeinfo after you forgot.

Cheers,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - The Qt Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4048 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150710/48b14177/attachment.bin>


More information about the Development mailing list