File tree Expand file tree Collapse file tree 1 file changed +47
-1
lines changed Expand file tree Collapse file tree 1 file changed +47
-1
lines changed Original file line number Diff line number Diff line change 1- <!-- $PostgreSQL: pgsql/doc/src/sgml/extend.sgml,v 1.38 2010/04/03 07:22:53 petere Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/extend.sgml,v 1.39 2010/06/01 02:31:36 momjian Exp $ -->
22
33 <chapter id="extend">
44 <title>Extending <acronym>SQL</acronym></title>
273273 &xoper;
274274 &xindex;
275275
276+ <sect1 id="extend-how">
277+ <title>Using C++ for Extensibility</title>
278+
279+ <indexterm zone="extend-Cpp">
280+ <primary>C++</primary>
281+ </indexterm>
282+
283+ <para>
284+ It is possible to use a compiler in C++ mode to build
285+ <productname>PostgreSQL</productname> extensions; you must simply
286+ follow the standard methods for dynamically linking to C executables:
287+
288+ <itemizedlist>
289+ <listitem>
290+ <para>
291+ Use <literal>extern C</> linkage for all functions that must
292+ be accessible by <function>dlopen()</>. This is also necessary
293+ for any functions that might be passed as pointers between
294+ the backend and C++ code.
295+ </para>
296+ </listitem>
297+ <listitem>
298+ <para>
299+ Use <function>malloc()</> to allocate any memory that might be
300+ freed by the backend C code (don't pass <function>new()</>-allocated
301+ memory).
302+ </para>
303+ </listitem>
304+ <listitem>
305+ <para>
306+ Use <function>free()</> to free memory allocated by the backend
307+ C code (do not use <function>delete()</> for such cases).
308+ </para>
309+ </listitem>
310+ <listitem>
311+ <para>
312+ Prevent exceptions from propagating into the C code (use a
313+ catch-all block at the top level of all <literal>extern C</>
314+ functions).
315+ </para>
316+ </listitem>
317+ </itemizedlist>
318+ </para>
319+
320+ </sect1>
321+
276322 </chapter>
You can’t perform that action at this time.
0 commit comments