long double in C APIs

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 16 03:33:21 PDT 2014


On 15 September 2014 23:24, David Nadlinger via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> There are currently a few pull requests related to interfacing to C's long
> double type on Win64, most of which have been already merged:
>  - https://github.com/D-Programming-Language/dmd/pull/3981
>  - https://github.com/D-Programming-Language/druntime/pull/958
>  - https://github.com/D-Programming-Language/dmd/pull/3990
>
> At first glance, this solution does not seem to be very appealing to me:
>
>  1. We need to teach everybody to not use 'real' when declaring C APIs, even
> though it's currently all over the place.
>
>  2. It effectively forces everybody to make all conversions to long double
> explicit in their code, at least if it they want to be cross-platform
> compatible. As the conversion will still be implicit on all platforms other
> than Win64 (and potentially some GDC/LDC targets), it seems like this could
> turn into another size_t-style portability trap.
>
> I guess this has already been discussed more extensively, though. I even
> seem to remember talking about making real equivalent to the 64 bit long
> double type on MSVC targets (which IIRC GDC is going to do anyway).

I would do it if GDC supported MSVC.  :o)

Real has /always/ been the equivalent of long double on all targets in
GDC's implementation.  The GCC compiler backend doesn't really keep
information about the largest float format supported by the CPU,
regardless of whether or not the size of long double is smaller.

Iain.


More information about the Digitalmars-d mailing list