[C++-sig] Boost Python wrapper<> causing a compile error C2664in vc++ 8.0

Matthew Scouten (TT) Matthew.Scouten at tradingtechnologies.com
Fri Sep 7 22:53:56 CEST 2007


I looked at Py++ but it seemed to require gcc. I cannot use that because
the company uses vc++ and the binary package I am wrapping was compiled
by vc++. Was I wrong? Can I use it with vc++? If I could use a gui that
would be fantastic. I have been finding boost::python to be under
documented.    

 

Also, how automated is that gui? If py++ is just a matter of writing the
same code in  python instead of c++ templates, I am more familiar with
c++ than python. 

 

The final lib to wrap is huge and problematic. There are pointers
returned and passed to python, vectors of pointers, virtual function
callbacks to be overloaded in python, overloaded functions,  functions
with default parameters, and all of the above in all combinations. 

 

From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On
Behalf Of Roman Yakovenko
Sent: Friday, September 07, 2007 2:54 PM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] Boost Python wrapper<> causing a compile error
C2664in vc++ 8.0

 

 

On 9/7/07, Matthew Scouten (TT)
<Matthew.Scouten at tradingtechnologies.com> wrote:

I am trying to wrap a class with virtual functions in c++, to be over
loaded in Python, and called from c++.
I have been working up to full functionality gradually but I have hit a
road block.
My code (trimmed to only relevant parts, with the identifiers changed to
protect the guilty): 

 class CProofOfConcept {

public:

                int x;

 

                CProofOfConcept(void);

                //CProofOfConcept(float f);

                std::string conceptProven(std::string = "My kingdom for
a valid arg!");

                virtual std::string reality(void) const;

                std::string ProofOfCallback();

                virtual std::string sureality(void);

                virtual ~CProofOfConcept(void);

 

private:

                float y;

};

 

class CProofOfConceptWrapper: public CProofOfConcept, public
wrapper<CProofOfConcept>

{

};

 

BOOST_PYTHON_MODULE(poc)

{

                class_<CProofOfConceptWrapper>("CPOC")

                                .def("reality",
&CProofOfConceptWrapper::reality)

                                .def_readwrite("x",
&CProofOfConceptWrapper::x)

                                .def("ProofOfCallback" ,
&CProofOfConceptWrapper::ProofOfCallback)

                                ;

}



Here is the code Py++ generated:


struct CProofOfConcept_wrapper : CProofOfConcept, bp::wrapper<
CProofOfConcept > {

    CProofOfConcept_wrapper(CProofOfConcept const & arg ) 
    : CProofOfConcept( arg )
      , bp::wrapper< CProofOfConcept >(){
        // copy constructor
        
    }

    CProofOfConcept_wrapper( )
    : CProofOfConcept( )
      , bp::wrapper< CProofOfConcept >(){ 
        // null constructor
    
    }
 

....

};


BOOST_PYTHON_MODULE(pyplusplus){
    bp::class_< CProofOfConcept_wrapper >( "CProofOfConcept" )    
        .def( bp::init< >() )    
        ....
}

P.S. If you just start with Boost.Python I suggest you to try Py++ (
http://language-binding.net/pyplusplus/documentation/tutorials/pyplusplu
s_gui.html ). I think you will not be disappointed. 

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/ 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070907/cfc55340/attachment.htm>


More information about the Cplusplus-sig mailing list