[C++-sig] Re: Cannot believe what my eyes see: ACCES VIOLATION...

David Abrahams dave at boost-consulting.com
Mon Sep 15 23:07:31 CEST 2003


yakumoklesk at yahoo.es writes:

> On 15 Sep 2003 at 11:11, David Abrahams wrote:
>
>> > #include <python.h>
>>   ^^^^^^^^^^^^^^^^^^^
>> 
>> Don't do this.  You should just include a Boost.Python header to get
>> python.h.  When I get rid of that, the only crash I can reproduce
>> goes away.  This is due to the debug-mode handling provided by
>> wrap_python.hpp as described in
>> http://www.boost.org/libs/python/doc/building.html#variants 
>
> I had already tested the program not including the python.h header but also crashed.
> The problem is that boost_python_debug.dll points to python23.dll instead of 
> python23_d.dll. How have I to modify the project that builds boost_python_debug.dll in 
> order to point to python23_d.dll instead of python23.dll?

Use Boost.Build.  It just works.

>> namespace py = boost::python;
>> 
>> void func()
>> {
>>     py::object main_module
>>            = py::extract<py::object>(PyImport_AddModule("__main__"));
>>     PyRun_SimpleString("a = 3");
>>     py::dict main_namespace(main_module.attr("__dict__"));
>> }
>
> This does not compile anyway, the first line gives this error:
>
> cannot convert from 'struct boost::python::extract<class boost::python::api::object>' to 
> 'class boost::python::api::object'

THat's your broken compiler at work.  Just add an extra "()" before
the ";".

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list