MUD Game Programmming - Python Modules in C++

Gabriel Genellina gagsl-py2 at
Wed Oct 14 16:13:33 CEST 2009

En Wed, 14 Oct 2009 05:19:06 -0300, Ulrich Eckhardt
<eckhardt at> escribió:

> Gabriel Genellina wrote:
>>> #ifdef _DEBUG
>>> #undef _DEBUG
>>> #include <Python.h>
>>> #define _DEBUG
>>> #else
>>> #include <Python.h>
>>> #endif
> [ keep Python from linking against non-existant debug libraries.]
>> No, don't do that. Just compile your application in release mode.
> Why not, does it break anything?

You have to ensure the same block is used everywhere <Python.h> is
included, or remember to always use "mypython.h", but there is still the
risk when adding some other external library.
The object layout is different in a debug build, and there are other
incompatible differences. Mixing code compiled in both modes hopefully
would generate a linker error, but if not, it may crash the application.
The debug flag for Python *should* be decoupled from the debug flag for
the application embedding it, but unfortunately it isn't. There is a
feature request at (the site doesn't work for me

Gabriel Genellina

More information about the Python-list mailing list