[Development] Proposing to officially allow C++20 types in Qt 6 ABIs

Marc Mutz marc.mutz at qt.io
Thu Jan 27 14:24:44 CET 2022



> Did I understand you correctly that we
> - would still guard any such method with an #if __cplusplus >= ...,

More likely __cpp_lib_span, etc, but yes in principle.

> - would compile our shipped artifacts in C++20 mode on all platforms where this is possible

I presume that would be necessary, yes.

But I confess to not having thought about pre-compiled binaries before hitting "send" 🙂 so good point.

> - and users still could compile their own code in C++17 mode on those platforms without issues?

That's the goal, yes. Within reason, of course.

There are two aspects here:

First, and easy, C++17 code will not see C++20 functions, so any C++20 code needs to be written such that the relation between a C++17 and C++20 build of Qt is the same as between a x.y and x.(y+1) build of Qt, respectively. Ie. backwards, but not forwards compatible. This means we can't have, say, virtual functions that use these types.

Second, and more subtly, this may unearth issues when a Qt compiled against C++20 is used to build an app in C++17 mode. I don't think we systematically test that. I'm thinking e.g. about issues of BC in the stdlib. Again, these issues would exist today, and not just on MSVC. E.g. we use std::function across the ABI boundary. If that were to change incompatibly, we'd need to ship separate C++17 and C++20 builds.

> - Lastly, in your proposal, platforms without C++20 support would still be able to build Qt, but lack the newer API? And if at some point they would gain a newer compiler, they would have to recompile Qt to get access to those methods, and linker errors otherwise?

Correct.

> If the above is correct (and it actually works), then I think we can do that. The only tricky part is the last point (you upgrade your compiler to support C++20, but your Qt still doesn't provide the C++20 methods you see in the headers), but I think this would be fine if it gets documented.

Thanks,
Marc


Marc Mutz

Principal Software Engineer

The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany

marc.mutz at qt.io<mailto:marc.mutz at qt.io>

www.qt.io<https://www.qt.io>

Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen

Sitz der Gesellschaft: Berlin,

Registergericht: Amtsgericht Charlottenburg,

HRB 144331 B

[https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/qt-company.png]<https://www.qt.io/>
[https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/facebook.png]<https://www.facebook.com/qt/>     [https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/twitter.png] <https://twitter.com/qtproject>    [https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/linkedin.png] <https://www.linkedin.com/company/the-qt-company/>        [https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/youtube.png] <https://www.youtube.com/QtStudios>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20220127/d3c9a37a/attachment-0001.htm>


More information about the Development mailing list