|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - Importing complex math functions?
Hi, I'm trying to access some complex number routines from C, but I can't get
it to work (using 0.167 on linux). Here is some sample code:
extern (C)
{
creal cexpl(creal); // e^x
real cabsl(creal); // |x|
}
As I understand, 'real' is equivalent to 'long double' in C, and 'creal' to
'long double complex', so this should work. But when I try it:
writefln( cabsl(3+4i) ); // Works, outputs 5
writefln( cexpl(1+0i) ); // Segmentation fault
In general, passing creal arguments and returning reals works, but returning
creals segfaults. Why doesn't this work? Does gcc do something fancy with
complex types in the C libraries?
Nick
Sep 29 2006
|