Add documentation section "Using C++ for Extensibility".
authorBruce Momjian
Tue, 1 Jun 2010 02:31:36 +0000 (02:31 +0000)
committerBruce Momjian
Tue, 1 Jun 2010 02:31:36 +0000 (02:31 +0000)
Craig Ringer

doc/src/sgml/extend.sgml

index 476af79bf4d15085dbb1426faa8dc826a3db74aa..1a4dd6abfbafba16c3d26106103bb1d7a0e1f0ec 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
  
   Extending <acronym>SQL</acronym>
   &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).
+      
+     
+    
+   
+
+  
+