git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 309193b)
Add documentation section "Using C++ for Extensibility".
Tue, 1 Jun 2010 02:31:36 +0000 (02:31 +0000)
Tue, 1 Jun 2010 02:31:36 +0000 (02:31 +0000)
Craig Ringer


diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml
index 476af79bf4d15085dbb1426faa8dc826a3db74aa..1a4dd6abfbafba16c3d26106103bb1d7a0e1f0ec 100644 (file)
--- a/doc/src/sgml/extend.sgml
+++ b/doc/src/sgml/extend.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/extend.sgml,v 1.38 2010年04月03日 07:22:53 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/extend.sgml,v 1.39 2010年06月01日 02:31:36 momjian Exp $ -->
<chapter id="extend">
<title>Extending <acronym>SQL</acronym></title>
@@ -273,4 +273,50 @@
&xoper;
&xindex;
+ <sect1 id="extend-how">
+ <title>Using C++ for Extensibility</title>
+
+ <indexterm zone="extend-Cpp">
+ <primary>C++</primary>
+ </indexterm>
+
+ <para>
+ It is possible to use a compiler in C++ mode to build
+ <productname>PostgreSQL</productname> extensions; you must simply
+ follow the standard methods for dynamically linking to C executables:
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ Use <literal>extern C</> linkage for all functions that must
+ be accessible by <function>dlopen()</>. This is also necessary
+ for any functions that might be passed as pointers between
+ the backend and C++ code.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Use <function>malloc()</> to allocate any memory that might be
+ freed by the backend C code (don't pass <function>new()</>-allocated
+ memory).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Use <function>free()</> to free memory allocated by the backend
+ C code (do not use <function>delete()</> for such cases).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Prevent exceptions from propagating into the C code (use a
+ catch-all block at the top level of all <literal>extern C</>
+ functions).
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ </sect1>
+
</chapter>
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /