Re: SPI-header-files safe for C++-compiler - Mailing list pgsql-patches

From Jacob Rief
Subject Re: SPI-header-files safe for C++-compiler
Date
Msg-id 20070702203325.156540@gmx.net
Whole thread Raw
In response to Re: SPI-header-files safe for C++-compiler  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: SPI-header-files safe for C++-compiler
List pgsql-patches
> Tom Lane writes:
> The problem that I see after trying the experiment, however, is that
> actually building Postgres using a C++ compiler would require changes
> enormously more invasive than just renaming some fields and function
> argument names.  And I have no confidence in our ability to *keep* the
> headers C++-clean if there's not a buildfarm member out there building
> it with a C++ compiler so it can gripe about re-introduction of C++
> keywords.  So I'm afraid the issue will just keep coming back.

I never was talking about compiling the whole Postgres-implementation with g++ (even if that would nice experience :)
It'sonly about a few header-files, were it would even be legal (but dirty) to patch them after compilation, since they
areabsolutely binary compatible. 

> Chuck mentioned the point that C++ rejects implicit casts from void*
> to something else, but there are a lot of other problems, including
> some that would require notational compromises I don't think we'd like
> to make.  Two examples:

> * g++ rejects struct assignment if either source or destination is
> accessed through a volatile pointer.  We do that in a number of places,
> mostly in xlog.c and bufmgr.c.  Options I can see are not good:
>     1: don't use volatile (not acceptable)
>     2: cast away volatile (probably breaks the guarantee we want)
>     3: do the assignment explicitly field-by-field (sucks from a
>         maintenance point of view, not to mention legibility)
>     4: use memcpy (sucks for performance because structs are small,
>         and probably requires casting away volatile, see #2)
>
> * I don't see how to make expression_tree_walker and
> expression_tree_mutator work reasonably nicely; g++ is too picky about
> the argument types of the walker/mutator function.

Only header files shall be C++ compatible. There is no reason and no need to make the whole implementation C++-conform.

> Anyway, at this point my concern is not so much whether we could fix
> it as what is the plan for keeping it fixed.

A best practice statement, telling developers not use C++-keywords as identifiers in header-files.

Regards, Jacob
--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

pgsql-patches by date:

Previous
From: "Chuck McDevitt"
Date:
Subject: Re: SPI-header-files safe for C++-compiler
Next
From: Tom Lane
Date:
Subject: Re: SPI-header-files safe for C++-compiler