
On Fri, May 25, 2012 at 8:37 AM, lcaminiti <lorcaminiti@gmail.com> wrote:
Hello all,
Boost.Python uses operator keywords in macro expansion. This is a bad idea because on some compilers like MSVC that implement and, or, etc using macros #define to &&, ||, these macros will not expand correctly when ciso646 is included before including python.hpp.
#include <ciso646>
// boost/python/operators.hpp BOOST_PYTHON_BINARY_OPERATOR(and, rand, &) BOOST_PYTHON_BINARY_OPERATOR(or, ror, |) ...
This will actually expand to:
BOOST_PYTHON_BINARY_OPERATOR(&&, rand, &) BOOST_PYTHON_BINARY_OPERATOR(||, ror, |)
And then expand the macro causing a compiler error because the operator code will have names like op_&&, op_||, etc instead of the intended op_and, op_or, etc.
An easy and safe fix should be to change the macro to move the _ to the macro call:
BOOST_PYTHON_BINARY_OPERATOR(_and, rand, &) BOOST_PYTHON_BINARY_OPERATOR(_or, ror, |)
Now _and, _or, etc are no longer keywords so it's safe to use them.
Sounds like a legitimate issue (as far as working around MSVC deficiencies); file a trac ticket and attach a patch? - Jeff