[Development] QProperty and library coding guide

Lars Knoll lars.knoll at qt.io
Fri Jul 17 09:25:04 CEST 2020



> On 16 Jul 2020, at 23:35, Thiago Macieira <thiago.macieira at intel.com> wrote:
> 
> On Thursday, 16 July 2020 13:16:41 PDT Giuseppe D'Angelo via Development 
> wrote:
>> Il 16/07/20 12:43, Volker Hilsheimer ha scritto:
>>> For pre-C++20 (where it’s possible to have zero-size structs), and for
>>> compilers that don’t respect the [[no_unqiue_address]] attribute, all
>>> these struct-instances are put into a union. In that case, a class using
>>> QProperty will be larger (by the same amount no matter the number of
>>> properties) than the same class in Qt 5. With C+++ 20 and compilers that
>>> do respect [[no_unique_address]], the size and layout of these classes
>>> will be the same.
>> I'm not fully understanding this last part -- does changing compiler
>> break ABI, because the implementation of properties change (from an
>> union to [[no_unique_address]] members)?
> 
> Yes.
> 
> Already sent a -2 to the commit that added this support, because it can't 
> work. The commit will need to be reverted.

Yes, it can and it does work. And it’s what we should be doing on compilers that support [[no_unique_address]]. 

It does mean that a pure C++17 and a C++20 build aren’t binary compatible, but I think we should pay that price.

If I remember correctly, the only compiler that doesn’t yet support it is MSVC. BC mainly matters on desktop Linux and those all support the feature, so we can enable it from the get go. 

Cheers,
Lars
> 
> -- 
> Thiago Macieira - thiago.macieira (AT) intel.com
>  Software Architect - Intel System Software Products
> 
> 
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development


More information about the Development mailing list