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

Re: server-side extension in c++

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: Igor <igor(at)carcass(dot)ath(dot)cx>, pgsql-general(at)postgresql(dot)org
Subject: Re: server-side extension in c++
Date: 2010-06-01 02:32:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Craig Ringer wrote:
> Igor wrote:
> > Hi All,
> > 
> > Is there an easy way to add c++ files to my simple pgsql module ? My Makefile 
> > is as follows - 
> > 
> > ===
> > MODULES = pg_uservars
> > DATA_built = pg_uservars.sql
> > PGXS := $(shell pg_config --pgxs)
> > include $(PGXS)
> > ===
> > 
> > I've got "pg_uservars.c" and "" and I'd like to compile via g++. 
> > I'm aware of c++ name [de]mangling, just looking if there's a standard way of 
> > using C++ when it comes to pgxs.  
> It should "just work". Simply make sure to follow the usual rules for
> calling into C++ code from C and vice versa:
> - Use "extern C" linkage for all functions that must be accessible by
>   dlopen(), and preferably also for any functions that you might take
>   a function pointer to and pass to C code
> - Never return new()'d memory that might be free()'d by the C code; use
>   malloc()
> - Never delete() memory that was malloc()'d by the C code; use free()
> - Never let an exception propagate into the C code; use a catch-all
>   block at the top level of all "extern C" functions
> ... and probably other things I've missed.

That is great new information.  I have created a new documentation
section called "Using C++ for Extensibility", and listed you as the
author in the CVS commit;  patch attached.  Thanks. 

  Bruce Momjian  <bruce(at)momjian(dot)us>

  + None of us is going to be here forever. +

Attachment: /rtmp/diff
Description: text/x-diff (1.8 KB)

In response to


pgsql-general by date

Next:From: Schwaighofer ClemensDate: 2010-06-01 02:33:51
Subject: Re: What Linux edition we should chose?
Previous:From: Nilesh GovindarajanDate: 2010-06-01 02:30:35
Subject: Re: What Linux edition we should chose?

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