C++ Headers

C++ Headers

Post by Tom La » Mon, 21 May 2001 09:37:24




> The only mention I see of this is in c.h:
>    #ifndef __cplusplus
>    #ifndef bool
>    typedef char bool;
>    #endif   /* ndef bool */
>    #endif   /* not C++ */
> If you need more cplusplus stuff, lets figure it out and add it.

Actually, that portion of c.h is a time bomb that is likely to blow up
in the face of some poor C++ user.  There's no guarantee that a C++
compiler's built-in bool type will be compatible with "char", is there?
If it happened to be, say, same size as "int", then a C++ module
would interpret lots of things differently from a C module.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

 
 
 

C++ Headers

Post by Christof Pet » Tue, 22 May 2001 18:07:29




> > The only mention I see of this is in c.h:

> >       #ifndef __cplusplus
> >       #ifndef bool
> >       typedef char bool;

> >       #endif   /* ndef bool */
> >       #endif   /* not C++ */

> > If you need more cplusplus stuff, lets figure it out and add it.

> Actually, that portion of c.h is a time bomb that is likely to blow up
> in the face of some poor C++ user.  There's no guarantee that a C++
> compiler's built-in bool type will be compatible with "char", is there?
> If it happened to be, say, same size as "int", then a C++ module
> would interpret lots of things differently from a C module.

This in fact has happened within ECPG. But since sizeof(bool) is passed to
libecpg it was possible to figure out which 'bool' is requested.

Another issue of C++ compatibility would be cleaning up the usage of
'const' declarations. C++ is really strict about 'const'ness. But I don't
know whether postgres' internal headers would need such a cleanup. (I
suspect that in ecpg there is an oddity left with respect to host variable
declaration. I'll check that later)

    Christof

---------------------------(end of broadcast)---------------------------


 
 
 

C++ Headers

Post by Nathan Mye » Thu, 24 May 2001 06:02:13



> > This in fact has happened within ECPG. But since sizeof(bool) is passed to
> > libecpg it was possible to figure out which 'bool' is requested.

> > Another issue of C++ compatibility would be cleaning up the usage of
> > 'const' declarations. C++ is really strict about 'const'ness. But I don't
> > know whether postgres' internal headers would need such a cleanup. (I
> > suspect that in ecpg there is an oddity left with respect to host variable
> > declaration. I'll check that later)

> 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 { ... }  

Nathan Myers

---------------------------(end of broadcast)---------------------------

 
 
 

C++ Headers

Post by Bruce Momji » Thu, 24 May 2001 07:17:33



> > > This in fact has happened within ECPG. But since sizeof(bool) is passed to
> > > libecpg it was possible to figure out which 'bool' is requested.

> > > Another issue of C++ compatibility would be cleaning up the usage of
> > > 'const' declarations. C++ is really strict about 'const'ness. But I don't
> > > know whether postgres' internal headers would need such a cleanup. (I
> > > suspect that in ecpg there is an oddity left with respect to host variable
> > > declaration. I'll check that later)

> > 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.

--
  Bruce Momjian                        |  http://candle.pha.pa.us

  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

---------------------------(end of broadcast)---------------------------

 
 
 

C++ Headers

Post by Nathan Mye » Thu, 24 May 2001 10:35:32




> > > > This in fact has happened within ECPG. But since sizeof(bool) is
> > > > passed to libecpg it was possible to figure out which 'bool' is
> > > > requested.

> > > > Another issue of C++ compatibility would be cleaning up the
> > > > usage of 'const' declarations. C++ is really strict about
> > > > 'const'ness. But I don't know whether postgres' internal headers
> > > > would need such a cleanup. (I suspect that in ecpg there is an
> > > > oddity left with respect to host variable declaration. I'll
> > > > check that later)

> > > 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.

Nathan Myers

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

 
 
 

C++ Headers

Post by Bruce Momji » Fri, 25 May 2001 00:44:43


Quote:> > > > 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.

--
  Bruce Momjian                        |  http://candle.pha.pa.us

  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate

message can get through to the mailing list cleanly

 
 
 

C++ Headers

Post by Nathan Mye » Fri, 25 May 2001 06:46:27



> > > > > 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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

 
 
 

C++ Headers

Post by Bruce Momji » Fri, 25 May 2001 08:00:59


Quote:> > 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.

Our C++ interface needs serious work, and I don't want to burden a
maintainer with adding muck for backward compatibility.

We do update libpq occasionally and don't keep link compatibility. We do
keep interface compatibility with the backend.

--
  Bruce Momjian                        |  http://candle.pha.pa.us

  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

 
 
 

1. C++ Headers

Is any support for reworking the postgres headers such that they can be used,
cleanly, in a C++ program?

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

2. LIKE Operator not working as with access 97

3. open server c++ headers

4. OCI insert array ! HELP !

5. APT LIB C++ Header Files

6. ODBC Error on IIS4

7. SQL header files for C, C++

8. Max DARI error

9. ODBC headers for C or C++

10. SQL server header files for C, C++

11. SQL Server header files for C, C++

12. C++, C++, C++, C++