Pycxx Debugmacro

In CXX/Python3/ExtentionType.hxx we have several blocks of the form:

#ifdef PYCXX_DEBUG
            std::cout << "extension_object_new()" << std::endl;
#endif

This is rather ugly, and can be tidied up by the following:

// wherever PYCXX_DEBUG is defined: for me, this is in CXX/WrapPython.h
#define PYCXX_DEBUG (1)

#ifdef PYCXX_DEBUG
#   define IF_PYCXX_DEBUG( x ) x
#else
#   define IF_PYCXX_DEBUG( x )
#endif

And then we can just write:

            IF_PYCXX_DEBUG( std::cout << "extension_object_new()" << std::endl; )

This is more succinct, reads better, and upholds indentation.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License