Re: C++ Headers

From: ncm(at)zembu(dot)com (Nathan Myers)
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: C++ Headers
Date: 2001-05-23 21:36:50
Message-ID: 20010523143650.N18121@store.zembu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 23, 2001 at 11:35:31AM -0400, Bruce Momjian wrote:
> > > > > We have added more const-ness to libpq++ for 7.2.
> > > >
> > > > Breaking link compatibility without bumping the major version number
> > > > on the library seems to me serious no-no.
> > > >
> > > > To const-ify member functions without breaking link compatibility,
> > > > you have to add another, overloaded member that is const, and turn
> > > > the non-const function into a wrapper. For example:
> > > >
> > > > void Foo::bar() { ... } // existing interface
> > > >
> > > > becomes
> > > >
> > > > void Foo::bar() { ((const Foo*)this)->bar(); }
> > > > void Foo::bar() const { ... }
> > >
> > > Thanks. That was my problem, not knowing when I break link compatiblity
> > > in C++. Major updated.
> >
> > Wouldn't it be better to add the forwarding function and keep
> > the same major number? It's quite disruptive to change the
> > major number for what are really very minor changes. Otherwise
> > you accumulate lots of near-copies of almost-identical libraries
> > to be able to run old binaries.
> >
> > A major-number bump should usually be something planned for
> > and scheduled.
>
> That const was just one of many const's added, and I am sure there will
> be more stuff happening to C++. I changed a function returning short
> for tuple length to int. Not worth mucking it up.
>
> If it was just that one it would be OK.

I'll bet lots of people would like to see more careful planning about
breaking link compatibility. Other changes that break link compatibility
include changing a struct or class referred to from inline functions, and
adding a virtual function in a base class.

It's possible to make a lot of improvements without breaking link
compatibility, but it does take more care than in C. If you wonder
whether a change would break link compatibility, please ask on the list.

Nathan Myers
ncm(at)zembu(dot)com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut - PostgreSQL 2001-05-23 22:00:44 pgsql/src/bin/scripts Makefile createlang.sh
Previous Message Nathan Myers 2001-05-23 21:21:14 Re: More pgindent follies