Re: [GENERAL] C++ port of Postgres

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
Subject: Re: [GENERAL] C++ port of Postgres
Date: 2016-08-31 13:41:26
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-general pgsql-hackers

[trimmed cc list because of big attachments]

On 8/16/16 4:22 PM, Jim Nasby wrote:
> Joy, do you have an idea what a *minimally invasive* patch for C++
> support would look like? That's certainly the first step here.

I developed a minimally invasive patch for C++ support a few years ago
shortly after I wrote that blog post. Since there appears to have been
some interest here now, I have updated that and split it up into logical

So here you go.

To build this, you need to configure with g++ <= version 5. (4.x works,
too.) g++ version 6 does not work yet because of the issues described
in patch 0013.

Then you also need to edit src/Makefile.custom and set

COPT = -fpermissive -Wno-sign-compare -Wno-write-strings

The -W options are optional just to reduce some noise. Cleaning up
those warnings can be a separate project that might also have some
benefit under C.

The -fpermissive option is a g++ specific option that reduces some
errors to warnings. (So this won't work with clang or other compilers
at all at this point.) In particular, C++ does not allow casting from
or to void pointers without a cast, but -fpermissive allows that. The
step from this to "real" C++ would be adding a bunch of casts around
things like malloc and palloc and other places. That would be mostly
busy work, so I have excluded that here.

The patches are numbered approximately in increasing order of dubiosity.
So 0001 is probably a straight bug fix, 0002 and 0003 are arguably
minor bug fixes as well. The patches through 0012 can probably be
considered for committing in some form. After that it gets a bit hackish.

Peter Eisentraut
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Fix-use-of-offsetof.patch text/x-patch 920 bytes
0002-Use-return-instead-of-exit-in-configure.patch text/x-patch 2.0 KB
0003-Add-missing-include-files-to-configure-tests.patch text/x-patch 1.7 KB
0004-Fix-LDFLAGS-test-for-C.patch text/x-patch 2.3 KB
0005-Add-test-for-Wmissing-prototypes.patch text/x-patch 2.7 KB
0006-Remove-unnecessary-prototypes.patch text/x-patch 4.9 KB
0007-Fix-incorrect-type-cast.patch text/x-patch 1.4 KB
0008-Add-necessary-type-cast.patch text/x-patch 764 bytes
0009-Rename-some-typedefs-to-avoid-name-conflicts.patch text/x-patch 10.3 KB
0010-Reorder-some-things.patch text/x-patch 3.9 KB
0011-Add-missing-fields-in-struct-initializations.patch text/x-patch 5.4 KB
0012-Separate-enum-from-struct.patch text/x-patch 1.4 KB
0013-Avoid-C-key-words.patch text/x-patch 2.3 KB
0014-Set-up-for-static-asserts-in-C.patch text/x-patch 1.5 KB
0015-Fix-function-prototypes-for-C.patch text/x-patch 6.2 KB
0016-Fix-fmgr_oldstyle-for-C.patch text/x-patch 7.3 KB
0017-Don-t-define-bool-in-C.patch text/x-patch 734 bytes
0018-Change-TimeoutId-from-enum-to-integer.patch text/x-patch 1.6 KB
0019-Add-explicit-cast-for-casting-away-volatile.patch text/x-patch 863 bytes
0020-Add-more-extern-key-words.patch text/x-patch 2.5 KB
0021-Workaround-for-using-typdef-ed-ints-in-loops.patch text/x-patch 6.4 KB
0022-Disable-conflicting-function.patch text/x-patch 854 bytes
0023-Add-C-linkage-to-replacement-declaration-of-fdatasyn.patch text/x-patch 751 bytes
0024-Make-inet_net_-to-C-linkage.patch text/x-patch 1.3 KB
0025-Add-C-linkage-to-functions-exported-by-plugins.patch text/x-patch 8.4 KB
0026-Add-C-linkage-to-client-libraries-in-non-systematic-.patch text/x-patch 4.6 KB
0027-Hack-Disable-volatile-that-causes-mysterious-compile.patch text/x-patch 1.5 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2016-08-31 13:43:28 Re: pg_sequence catalog
Previous Message David Steele 2016-08-31 13:39:01 Re: some requests on auditing

Browse pgsql-general by date

  From Date Subject
Next Message Karl O. Pinc 2016-08-31 14:07:39 postgresql.conf RH comment, and a systemd RH note
Previous Message Bastien Bodart 2016-08-31 12:43:30 Filters not supported for LDAP authentication