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

From Jacob Rief
Subject SPI-header-files safe for C++-compiler
Date
Msg-id 1182984211.3620.43.camel@ruben
Whole thread Raw
Responses Re: SPI-header-files safe for C++-compiler
List pgsql-patches
This is a request I posted in February. The thread was named "Writing
triggers in C++". However I did not supply a patch then, and some people
misunderstood my problem. I will try to explain it again:

My problem is, I wrote some triggers in C using the SPI-API. Those
triggers call some functions defined in an external C++ library. In
order to use name-mangled functions, namespaces and C++-header-files,
provided by this library, I have to use a C++ compiler to compile my
trigger-functions. But the C++-compiler rejects to compile legal C code,
because some of the included Postgres-headers, ie. postgres.h,
executor/spi.h, commands/trigger.h, fmgr.h use a few C++ keywords to
defined a some struct members and function arguments. The incriminating
C++-keywords used in the Postgres-headers are: 'typeid', 'typename' and
'using'.

It would do no harm to the Postgres-sources if these keywords would be
replaced with a similar identifier. I wrote a patch which applies cleanly
onto version 8.2.4 (and 8.2.3) and keeps the Postgres binary compatible to
an unpatched version.

I would appreciate to see this patch applied onto the Postgres-sources.
Other authors using the SPI-API together with a C++-compiler would also
benefit from this patch.

Regards, Jacob

Attachment

pgsql-patches by date:

Previous
From: "Pavan Deolasee"
Date:
Subject: HOT latest patch - version 8
Next
From: Tom Lane
Date:
Subject: Re: Load Distributed Checkpoints, final patch