Skip site navigation (1) Skip section navigation (2)

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

From: "Marko Kreen" <markokr(at)gmail(dot)com>
To: "Jacob Rief" <jacob(dot)rief(at)gmx(dot)at>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, neilc(at)samurai(dot)com, pgsql-patches(at)postgresql(dot)org, andrew(at)dunslane(dot)net
Subject: Re: SPI-header-files safe for C++-compiler
Date: 2007-06-29 10:02:26
Message-ID: e51f66da0706290302w2bbea43ds1820ce8f6541297d@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-patches
On 6/29/07, Jacob Rief <jacob(dot)rief(at)gmx(dot)at> wrote:
> On Thu, 2007-28-06 at 01:15 -0400, 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
>
> No, wrong. Adding extern "C" does not fix the C++-keywords as identifiers
> problem. Adding extern "C" only tells the compiler to switch off
> name-mangling. A C++-compiler does not allow any kind of plain-old C in
> such blocks. With some drawbacks, it is even perfectly legal to use some
> C++ features inside an extern "C" block.

I think you are better off wrpapping your C++ code to small
pure-C module and export only that to Postgres-interfacing
C code.  Thus you keep away making C++ seeing Postgres code.

It is really a mistake to think C as subset of C++.  They are
really different languages.  C-as-subset-of-C++ works only
with trivial C code.  If you have big, old, real-life codebase
like Postgres, it really does not pay off to force it to comply
with C++ rules.  Just to avoid the work of writing intermediate
wrapper code.

-- 
marko

In response to

pgsql-patches by date

Next:From: Patrick WelcheDate: 2007-06-29 12:06:42
Subject: Re: configure.in / xml / quoting trouble
Previous:From: Jacob RiefDate: 2007-06-29 09:34:59
Subject: Re: SPI-header-files safe for C++-compiler

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group