ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
ActivePython 2.5
Python Documentation
Extending and Embedding
1. Extending Python with C or C++
1.1 A Simple Example
1.2 Intermezzo: Errors and Exceptions
1.3 Back to the Example
1.4 The Module's Method Table and Initialization Function
1.5 Compilation and Linkage
1.6 Calling Python Functions from C
1.7 Extracting Parameters in Extension Functions
1.8 Keyword Parameters for Extension Functions
1.9 Building Arbitrary Values
1.10 Reference Counts
1.11 Writing Extensions in C++
1.12 Providing a C API for an Extension Module

MyASPN >> Reference >> ActivePython 2.5 >> Python Documentation >> Extending and Embedding >> 1. Extending Python with C or C++
ActivePython 2.5 documentation


1.11 Writing Extensions in C++

It is possible to write extension modules in C++. Some restrictions apply. If the main program (the Python interpreter) is compiled and linked by the C compiler, global or static objects with constructors cannot be used. This is not a problem if the main program is linked by the C++ compiler. Functions that will be called by the Python interpreter (in particular, module initialization functions) have to be declared using extern "C". It is unnecessary to enclose the Python header files in extern "C" {...} -- they use this form already if the symbol "__cplusplus" is defined (all recent C++ compilers define this symbol).

See About this document... for information on suggesting changes.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved