[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] My code doesn't float
From: |
Paul Colby |
Subject: |
Re: [Chicken-users] My code doesn't float |
Date: |
Tue, 16 Aug 2011 22:04:30 -0700 |
Got it,
I finally resorted to clang and got a warning about implicit declarations in c
compilation.
Apparently, one needs something to the effect,
(foreign-declare "float testFloat(float);")
(foreign-declare "double testDouble(double);")
in stest1.scm to tell c that testFloat and it's argument are floats. Well, that
only took most
of a day to learn....
On Aug 16, 2011, at 9:15 PM, Paul Colby wrote:
> Hi,
>
> I'm running v4.7.0 installed with brew on my mac running 10.6. Before I do a
> complete reinstall of my operating system I'd like to know if foreign works
> for
> anyone? I've made a c-file,
>
> -------------------------- test1.c -----------------------
> #include <stdio.h>
>
> float testFloat(float f)
> {
> printf("Float: %f\n",f);
> return 2.0*f;
> }
>
> double testDouble(double d)
> {
> printf("Double: %lf\n",d);
> return 2.0*d;
> }
> ------------------------------ end of file -----------------
> These functions are compiled into a scheme
> file using
> csc stest2.scm test1.c
> where the scheme file is,
> ------------------------ stest2.scm ----------------------
> (import foreign)
> (define testFloat (foreign-lambda float testFloat float))
> (define testDouble (foreign-lambda double testDouble double))
> (print (testFloat 3.2))
> (print (testDouble 3.2))
> ----------------------- end of file ------------------------
> running ./stest2 gives
> ------------------------ output ---------------------------
> Float: -0.000000
> 17.0
> Double: 3.200000
> 17.0
> ------------------------ end of output -------------------
>
> Am I missing something fundamental or is 3.2 == -0.0 and
> 17==6.4?
>
> Thanks
> Paul C.
>
>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-users