On Sep 9, 2009, at 10:23 AM, Lisandro Dalcin wrote:

> My GCC manual page says this:
>
>  To extract the real part of a complex-valued expression EXP, write
> `__real__ EXP'.  Likewise, use `__imag__' to extract the imaginary
> part.  This is a GNU extension; for values of floating type, you  
> should
> use the ISO C99 functions `crealf', `creal', `creall', `cimagf',
> `cimag' and `cimagl', declared in `<complex.h>' and also provided as
> built-in functions by GCC.
>
> So it seems that __real__ and __imag__ are actually GNU extensions...
> Then these defines:
>
>     #define __Pyx_REAL_PART(z) __real__(z)
>     #define __Pyx_IMAG_PART(z) __imag__(z)
>
> could potentially not work on compilers other than GCC...

Hmm... true. The advantage of __real__ and __imag__ are that they  
work for non-floating point types (when the compiler supports them),  
they are the same for all types, and perhaps most importantly, they  
are valid lvalues. The IBM and CodeWarrior compilers seem to support  
this extension, MSVC isn't even c99 compliant. Is there a c99 way of  
getting the real and imaginary parts of a complex as an lvalue?

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to