operator double() surprise in cxx

Jeremy Yallop jeremy at jdyallop.freeserve.co.uk
Fri Apr 30 07:23:42 EDT 2004


Isaac To wrote:
>>>>>> "Benoît" == Benoît Dejean <bnetNOSPAM at ifrance.com> writes:
> 
>     Benoît> Le Thu, 29 Apr 2004 21:35:51 -0500, John Hunter a écrit :
>     >>  I am using pycxx 5.2.2 to generate some extension code.  I want to
>     >> extract some doubles from some python sequences
>     >> 
>     >> When I do
>     >> 
>     >> double l( Py::Float(rect[0]) ); double b( Py::Float(rect[1]) );
> 
>     Benoît> everything that looks/tastes/sounds like a function declaration
>     Benoît> is (even with parameters.
> 
> Is it really a bug in g++?  

No.

> No matter how I look at
> 
>   Py::Float(rect[0])
> 
> it does not look like a type "Py::Float*" that is indicated by the error
> message.

As a declaration, it's a zero-length array of Py::Float, with a
parenthesized declarator, i.e. the same as 

    Py::Float rect[0];

As a parameter declaration, it's equivalent to

    Py::Float *rect;

because of the way C++ handles arrays.

Jeremy.



More information about the Python-list mailing list