[C++-sig] C1204:Compiler limit quick question

David Abrahams dave at boost-consulting.com
Fri Dec 6 15:47:39 CET 2002


"Scott A. Smith" <ssmith at magnet.fsu.edu> writes:

> I have a quick question on avoiding error C1204 when using
> BP and MSVC++ V6. I break up my code into separate files to
> avoid the problem as directed in
>
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/p
> ython/doc/v2/faq.html#c1204
>
> Works great. But when it comes to doing so in a class I don't
> see how to get an instance of my class into the module definition.
> If I have my BP module (following along with the FAQ)
>
> BOOST_PYTHON_MODULE(my_module)
> {
>    def("foo", foo);
>    ...
>    class_<my_class>("my_class", init<>())
>    ...
>    ;
>    more_of_my_class(x);   <======= ???
> }
>
> void more_of_my_class(class<my_class>& x)
> {
>    x
>      .def("baz", baz)
>      .add_property("xx", &my_class::get_xx, &my_class::set_xx)
>      ;
>    ...
> }
>
> How to I get an reference to an instance of my_class?
> That is, where do I get the x for the line "more_of_my_class(x);"
> assuming this is the correct means of breaking up the class?

option 1:

    BOOST_PYTHON_MODULE(my_module)
    {
       def("foo", foo);
       ...
       class_<my_class> x("my_class", init<>())

       x
          .def(...)
       ...
       ;

       more_of_my_class(x);
    }

option 2:

    BOOST_PYTHON_MODULE(my_module)
    {
       def("foo", foo);
       ...

       more_of_my_class(
           class_<my_class>("my_class", init<>())
                .def(...)
                ...

       ); 
    }
 
It's just regular C++.

-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list