From: Bruce Momjian Date: Tue, 1 Jun 2010 02:31:36 +0000 (+0000) Subject: Add documentation section "Using C++ for Extensibility". X-Git-Tag: REL9_0_BETA2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b67fbb6c57c366762c23f6957a256ffce33815ce;p=postgresql Add documentation section "Using C++ for Extensibility". Craig Ringer --- diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml index 476af79bf4..1a4dd6abfb 100644 --- a/doc/src/sgml/extend.sgml +++ b/doc/src/sgml/extend.sgml @@ -1,4 +1,4 @@ - + Extending <acronym>SQL</acronym> @@ -273,4 +273,50 @@ &xoper; &xindex; + + Using C++ for Extensibility + + + C++ + + + + It is possible to use a compiler in C++ mode to build + PostgreSQL extensions; you must simply + follow the standard methods for dynamically linking to C executables: + + + + + Use extern C linkage for all functions that must + be accessible by dlopen(). This is also necessary + for any functions that might be passed as pointers between + the backend and C++ code. + + + + + Use malloc() to allocate any memory that might be + freed by the backend C code (don't pass new()-allocated + memory). + + + + + Use free() to free memory allocated by the backend + C code (do not use delete() for such cases). + + + + + Prevent exceptions from propagating into the C code (use a + catch-all block at the top level of all extern C + functions). + + + + + + +