[Development] QList

Olivier Goffart olivier at woboq.com
Thu Mar 30 08:18:52 CEST 2017

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*)"

  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.

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.


Woboq - Qt services and support - https://woboq.com - https://code.woboq.org

More information about the Development mailing list