[24 of 26] Compiling C2HS.C.Info ( src/C2HS/C/Info.hs, dist/build/c2hs/c2hs-tmp/C2HS/C/Info.o )src/C2HS/C/Info.hs:117:53: Not in scope: type constructor or class `CLDouble'src/C2HS/C/Info.hs:142:70: Not in scope: type constructor or class `CLDouble'
Long double wasn't standardised before C99 and afaik the FFI addendum doesn't specify any particular C standard to adhere to, which means that GHC (without CLDouble) right now doesn't comply with the FFI although CLDouble does not have to be quad precision.
I opt for quick re-inclusion of CLDouble, be it as quad precision or not. An alias to CDouble, or a binding to the x87's 80bit type is a perfectly ok thing to do.
CLDouble needs to be the same as the C long double type, so things don't go wrong when using the FFI with long doubles.
Right, and adding a long double primitive type to GHC is not at all trivial. I thought about doing an implementation in Haskell using the FFI, but that wouldn't work because the key thing you need to be able to do with a CLDouble is pass it to a foreign function, and for that we need support in the native code generator. The primitives could be implemented using the FFI like we do for the 64-bit integral types on a 32-bit platform (although that's not entirely satisfactory).
As a workaround, code that needs CLDouble can go via a C wrapper that takes a CLDouble *. Avoid manipulating CLDouble directly in Haskell, just talk in terms of pointers to CLDouble.
CLDouble needs to be the same as the C long double type, so things don't go wrong when using the FFI with long doubles.
But there's no reliable agreement between compilers or even compiler switches on what a long double is. VS 2010 interprets it as double (96/80 bits), whereas gcc on the same will generate code for 96 bit floats on 386 and 128 bits of precision for amd64 (you can switch behaviour with -m128bit-long-double).
Implementing quad precision support doesn't fix the problem of not being able to know what a long double is without knowing the way the code to be interfaced to was compiled, whereas not providing an alias to CDouble breaks now working stuff for no reason at all.
Proper CLDouble support would either involve switches to select the proper interpretation of "long double" and explicit types for every supported bit width to interface to mixed code.
As a workaround, code that needs CLDouble can go via a C wrapper that takes a CLDouble *. Avoid manipulating CLDouble directly in Haskell, just talk in terms of pointers to CLDouble.