[C++-sig] Function with an argument passed by reference

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Mon Jan 5 17:52:52 CET 2004


The problem is surely that you cannot have a reference on an integer in
Python for number types are immutable. If "x" can be modified you should
write a small wrapper that returns the new value of 'x' and take an
integer without reference.

Pierre

Le lun 05/01/2004 à 17:42, Gilles Orazi a écrit :
> Hello,
> 
> I am trying to wrap a function declared like that:
> void myFunc(int& x) ;
> 
> If I wrap it like that:
> .def("myFunc", myFunc);
> my program compiles but when I call this function from Python I get an
> error message:
> "TypeError: bad argument type for built-in operation"
> 
> I looked through the mailing list archive and the various boost.python
> documentations but I did not found the answer.
> 
> Thanks by advance for the help.
> Regards,
> 
> 
> Dr Gilles Orazi
> Data Systems, R&D Software Engineer
> Scientific Instruments
> Varian JMBS S.A.S               
> 1 Rue Hector Berlioz      
> ZAC DES PLANS   
> F-38600 FONTAINE
> FRANCE
> 
> Tel: +33 4 76 53 35 80
> Fax: +33 4 76 53 35 89
> 
> gilles.orazi at varianinc.com
> http://www.varianinc.com
> 
> Inspiring Excellence"
> 
> 
> ______________________________________________________________________
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68 





More information about the Cplusplus-sig mailing list