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
nt 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 to python, but exposing functions like the above is step one for me. Thanks again, Oded --- On Mon, 8/2/10, Nat Goodspeed wrote: > From: Nat Goodspeed >

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