2017年6月12日 星期一

Connect C++ to Python

Background

    In order to support features such as function overloading and template, C++ applies the name mangling technique.   However, the C++ standard does not restrict how to do it.  Therefore, every vendor who implements the C++ compiler may do it in his own way.  This fact makes C++ hard to connect with other languages.
    With this in mind, I always think the only way to connect C++ with other languages is through the C interface.  Until I saw Boost.Python.

Boost.Python

    This module provides a convenient way to build such connection.  With this module, you don't even need to change your C++ code at all (non-intrusive, see its Quick Start for more detail).  However, when it comes to more advanced features such as the polymorphism and the template, one should do some effort to make it work...