[Openmcl-devel] Bug receiving floats or doubles in callbacks

Luis Oliveira luismbo at gmail.com
Fri Aug 5 04:28:22 UTC 2005


Hello,

Callbacks in OpenMCL seem to receive single- or double-float
arguments incorrectly. Here's an example:

  #include <stdio.h>

  void expect_float(float (*f)(float))
  {
      printf("f(42.0f) => %f\n", f(42.0f));
  }

  void expect_double(double (*f)(double))
  {
      printf("f(42.0) => %f\n", f(42.0));
  }


Having compiled and loaded the above C code:

  ? (defcallback return-float (:single-float n :single-float)
      (format t "Lisp side got: ~A~%" n)
      42.0)
  RETURN-FLOAT

  ? (external-call "_expect_float" :address return-float)
  f(42.0f) => 42.000000
  Lisp side got: 1.4814527E-39
  NIL

  ? (defcallback return-double (:double-float n :double-float)
      (format t "Lisp side got: ~A~%" n)
      42.0d0)
  RETURN-DOUBLE

  ? (external-call "_expect_double" :address return-double)
  f(42.0) => 42.000000
  Lisp side got: 2.2434418562267333D-308
  NIL


I hope this report helps.

-- 
Luis Oliveira
luismbo (@) gmail (.) com
Equipa Portuguesa do Translation Project
http://www2.iro.umontreal.ca/~pinard/po/registry.cgi?team=pt




More information about the Openmcl-devel mailing list