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

From: "Jacob Rief" <jacob(dot)rief(at)gmx(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, neilc(at)samurai(dot)com
Cc: pgsql-patches(at)postgresql(dot)org, andrew(at)dunslane(dot)net
Subject: Re: SPI-header-files safe for C++-compiler
Date: 2007-06-28 10:08:37
Message-ID: 20070628100837.172990@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> Sure, but we don't break them just on a whim. The bottom line here is
> whether we are going to make a real commitment to making C++ usable as
> a backend extension language --- and for the reasons I mentioned, that
> would entail a lot more than renaming a few identifiers. It was already
> pointed out upthread that wrapping the inclusions in extern "C" {...}
> would fix the identifier part of the problem from the user side, so I do
> not see the point of fixing it from our side unless we are prepared to
> buy into a lot of other changes. A C++ writer who is unwilling to add
> the extern{} bit around inclusions of C headers seems unlikely to "work
> with us" as regards to error-throwing conventions, for instance.

Adding an extern "C" arround the header files is not the problem, altough it would make life a little easier. I have often seen it in C-only header files, and it will do no harm to anybody using a C-only compiler.

The real problem are the C++-keyword used in spi.h and trigger.h
The C++ compiler (tested with gcc 4.1.0) even complains, if C++ keywords are used inside extern "C" { ... } blocks. The extern "C" only tells the compiler to switch off name-mangling - it does not allow any kind of plain-old C. With some drawbacks, it is perfectly legal to use C++ features inside an extern "C" block.

I am speaking about 1 function argument, where it absolutely doesn't matter, how it is named in a header files.
And I am speaking about 5 struct member where it should not be a real problem for client libraries to rename them to something very similar.

If there is any chance to get this patch applied, I will of course regenerate it out of the HEAD-revision of the CVS repository. If there is any objection about the terminology of the renamed keywords, lets discuss. If, however clients of spi.h and trigger.h shall never, ever even think about using a C++ compiler in their projects, I will stop any discussion here and patch each newer version of Postgres for my own private fork.

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 Susanne Ebrecht 2007-06-28 11:31:17 rename of a view
Previous Message Heikki Linnakangas 2007-06-28 09:14:05 Re: Load Distributed Checkpoints, final patch