[Development] QList

Marc Mutz marc.mutz at kdab.com
Thu Mar 30 08:32:24 CEST 2017


On Thursday 30 March 2017 08:18:52 Olivier Goffart wrote:
> On Donnerstag, 30. März 2017 07:20:11 CEST Marc Mutz wrote:
> > On Wednesday 29 March 2017 22:12:30 Thiago Macieira wrote:
> > > On quarta-feira, 29 de março de 2017 11:11:58 PDT Marc Mutz wrote:
> > > > Keyword: inline namespaces. This is the C++ mechanism for API
> > > > versioning. It allows to make that totally transparent. Why you find
> > > > that so odd as to be lacking for words is beyond me.
> > > 
> > > Inline namespaces do not solve the binary compatibility problem. They
> > > should not be used in Qt API for versioning.
> > > 
> > > Instead, do what you said before: create a V2 class.
> > 
> > Since the two are totally identical, except that inline namespaces are
> > transparent to the user, please explain what leads you to this
> > distinction.
> 
> Library 1:
> 
>  inline namespace v1 { class Foo {}; }
> 
> Library 2:
> 
>  LIBRARY2_EXPORT void registerPlugin(Foo*);
>     -> symbol gets mangled as "registerPlugin(v1::Foo*)"
> 
> Application:
> 
>   registerPlugin(new Foo);
>      -> calls exported symbol "registerPlugin(v1::Foo*)"
> 
> 
> When Library 1 puts Foo in the v2 inline namespace,  recompile Library2 and
> the exported symbol becomes "registerPlugin(v2::Foo*)". If Application is
> not recompiled, it will not work as the old symbol is no longer found.

Well, of couse. That's like removing the QFoo overload when you add QFooV2. 
Don't do that. You need to keep the v1::Foo definition as well as the v1::Foo 
overload, just as you need to keep the QFoo definition and the QFoo overload, 
when you add v2.

> So what that means is that technically, Library 1 did not break its binary
> compatibility.  But any library using Library 1 in their ABI is breaking
> compatibility when they get recompiled.
> 
> GCC's ABI tag extension have the exact same problem.

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts



More information about the Development mailing list