Clemens Wrote:

> I have a stupid problem linking D with C. This is with D 1.062, haven't tried 
> D2. So say I have two files:
> 
> ------ cfmt.c --------
> 
> #include <string.h>
> 
> char* myfmt(double x)
> {
>       static char buf[40];
>       sprintf(buf, "%f", x);
>       return buf;
> }
> 
> ------- test.d --------
> 
> extern(C) char* myfmt(double x);
> 
> void main()
> {
>       myfmt(42.3);
> }
> 
> ---------------------------
> 
> and I compile and link them as follows:
> 
> > dmc -c cfmt.c
> > dmd test.d cfmt.obj
> > test.exe
> 
> I get the runtime error "Floating point not loaded". No exception or 
> anything, the executable just terminates with that message on the terminal. I 
> found a short paragraph about that runtime error on
> http://www.digitalmars.com/ctg/runtime.html
> but it wasn't too helpful; a quick grep showed me that _fltused occurs in 
> both cfmt.obj and test.obj.
> 
> Anyone seen this before? What can I do? I'm pretty sure this used to work 
> with an older version. The actual real-world use case is linking to Lua, 
> which bombs out with the same message once you use the string concatenation 
> operator with a numeric argument. I used the Lua binding from dsource which 
> comes with a precompiled library, and just to be sure I then compiled my own 
> version of Lua with dmc; to no avail.
> 
> Clemens

FWIW, I found a workaround to this: if I specify to link with snn.lib 
explicitly on the command line, then everything seems to work. I'm a bit 
surprised since I thought that snn.lib is pulled in automatically. Is this a 
bug in DMD, in Optlink, or by some strange twist of fate expected behavior?

Clemens

Reply via email to