Re: [C++-sig] Calling a C++ function with arguments by reference (lvalues)

2010-08-02 Thread Nat Goodspeed
Oded Padon wrote: There is another reason why I think this has to be possible. > It is possible using ctypes. Using ctypes with the same C++ > code written above (except for extern "C"), the following python code: import ctypes; lib_cpp = ctypes.CDLL('./test_cpp.so') result = ctypes.c_int(0);

Re: [C++-sig] Calling a C++ function with arguments by reference (lvalues)

2010-08-02 Thread Jim Bosch
On 08/02/2010 01:46 PM, Oded Padon wrote: import ctypes; lib_cpp = ctypes.CDLL('./test_cpp.so') result = ctypes.c_int(0); lib_cpp.add(1, 2, ctypes.byref(result)); print result; prints: "c_long(3)" I do prefer however to use boost.python, as I would at a later stage want to expose C++ classes t

Re: [C++-sig] Calling a C++ function with arguments by reference (lvalues)

2010-08-02 Thread Oded Padon
Thank you for your rapid response. I had a typo in my code. It should have been: void add(int const a, int const b, int & c) { c = a + b; } i.e. the last argument is passed by non-const reference. One solution is indeed to rewrite the function to accept either a python object (class, dict, etc

Re: [C++-sig] Calling a C++ function with arguments by reference (lvalues)

2010-08-02 Thread Nat Goodspeed
Oded Padon wrote: The C++ code is: void add(int const a, int const b, int const& c) { c = a + b; } This doesn't even compile under g++ 4.0.1 (Mac): error: assignment of read-only reference 'c' I hope you're not using a compiler that accepts such code as legal? I must emphasize that I w

[C++-sig] Calling a C++ function with arguments by reference (lvalues)

2010-08-02 Thread Oded Padon
Hello everybody, I'm very new to Boost.Python, and I just spent hours trying to do something trivial, and couldn't get it. The C++ code is: void add(int const a, int const b, int const& c) { c = a + b; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("add", add)

[C++-sig] division operator in 3.1

2010-08-02 Thread Trigve Siver
Hi, I've found bug in boost python with division operator. Division operator with custom types doesn't work with python 3.1. It is because there were some changes in this regard in python 3. I've created ticket with patch https://svn.boost.org/trac/boost/ticket/4497 . Can somebody look at i