The Python documentation has a chapter on Extending and Embedding Python with C.
With good enough coding conventions this can by applied to C++ code. You will use extern "C"
to declare functions coded in C++ callable from C.
Be careful to avoid throw
ing a C++ exception to Python code.
On Linux, see also dlopen(3) and dlsym(3) and the C++ dlopen mini howto.
Python is open source. You should consider downloading its C source code and studying it.
Be aware of the GIL in Python. Multi-threading C++ code will be tricky.
Consider also generating C or C++ code with tools like RefPerSys or ANTLR, or writing in Python your C or C++ code generator.
Perhaps use static source code analyzers (like Frama-C or Bismon) on your C source code.
Be aware that C and C++ are different programming languages. See this and n1570 and n3337 or better.
PS. For Bismon or RefPerSys please contact me by email to basile@starynkevitch.net
and basile.starynkevitch@cea.fr
, but mention the URL of your question here in your email.