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

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

From: Jacob Rief <jacob(dot)rief(at)gmx(dot)at>
To: pgsql-patches(at)postgresql(dot)org
Subject: SPI-header-files safe for C++-compiler
Date: 2007-06-27 22:43:30
Message-ID: 1182984211.3620.43.camel@ruben (view raw or flat)
Thread:
Lists: 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: postgresql-8.2.4-c++-safe.patch
Description: text/x-patch (52.0 KB)

Responses

pgsql-patches by date

Next:From: Tom LaneDate: 2007-06-28 00:19:48
Subject: Re: Load Distributed Checkpoints, final patch
Previous:From: Pavan DeolaseeDate: 2007-06-27 09:06:06
Subject: HOT latest patch - version 8

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