Re: SPI-header-files safe for C++-compiler

From: "Jacob Rief" <jacob(dot)rief(at)gmx(dot)at>
To:
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: SPI-header-files safe for C++-compiler
Date: 2007-07-02 20:33:25
Message-ID: 20070702203325.156540@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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's only about a few header-files, were it would even be legal (but dirty) to patch them after compilation, since they are absolutely 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

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-07-02 20:57:22 Re: SPI-header-files safe for C++-compiler
Previous Message Chuck McDevitt 2007-07-02 16:01:47 Re: SPI-header-files safe for C++-compiler