From b67fbb6c57c366762c23f6957a256ffce33815ce Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 1 Jun 2010 02:31:36 +0000 Subject: [PATCH] Add documentation section "Using C++ for Extensibility". Craig Ringer --- doc/src/sgml/extend.sgml | 48 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) 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). + + + + + + + -- 2.40.0