Boost help please

David Abrahams dave at boost-consulting.com
Sun Mar 23 03:04:14 CET 2003


Jim <REMOVEjimdon at sympatico.caREMOVE> writes:

> Hi,
>
> I am switching some C++ code over to use boost ... but i am having
> some problems just getting things to compile ... the compile error is
> not very helpful so i'll leave it out for now ... the problem i think
> is more related to the fact i need return a structure from a boost
> function .... can anyone help ;-)

Please post Boost.Python questions to the c++-sig:
http://mail.python.org/mailman/listinfo/c++-sig


>
> The my attempt at a boosted function is here:
> ---------------------------------------------
>
> struct boardInfoStruct {
>    double d1;
>    double d2;
>    double d3;
>    double d4;
>    double d5;
>    double d6;
>    double d7;
>    double d8;
>    long l1;
>    long l2;
>    long l3;
>    long l4;
> };
>
> boardInfoStruct BOOSTED_cosim_get_board()
> {
>    boardInfoStruct * ret = new boardInfoStruct();
>
>    ret.d1 = theboard.x60_clk/1e6;
>    ret.d2 = theboard.pwm_clk/1e6;
>    ret.d3 = theboard.utx_clk/1e6;
>    ret.d4 = theboard.urx_clk/1e6;
>    ret.d5 = theboard.local_ref_clk/1e6;
>    ret.d6 = theboard.pcr_ref_clk/1e6;
>    ret.d7 = theboard.mod_ref_clk/1e6;
>    ret.d8 = theboard.demod_ref_clk/1e6;
>
>    ret.l1 = theboard.mod_utopia;
>    ret.l2 = theboard.demod_utopia;
>    ret.l3 = theboard.dac_type;
>    ret.l4 = theboard.adc_type;
>
>    return ret;
>
> }

Why not just expose boardInfoStruct?

    class_<boardInfoStruct>("board_info")
        .def_readwrite("d1", &boardInfoStruct::d1)
        .def_readwrite("d2", &boardInfoStruct::d2)
        .def_readwrite("d3", &boardInfoStruct::d3)
        ...
        ;


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




More information about the Python-list mailing list