chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] incorrect warning during compilation


From: Kristian Lein-Mathisen
Subject: Re: [Chicken-hackers] incorrect warning during compilation
Date: Wed, 25 Jun 2014 16:13:52 +0200


Oh, I see. I though it was meant to be used interchangeably. I can't use string->blob, though, because that will copy the data and I need to modify it from C. What foreign type should I use for this sort of thing?

- (c-pointer char) with (location "string") works, but is a lot of typing

- scheme-pointer seems to work, but:

requires type cast in C:

(print ((foreign-lambda* c-string ((scheme-pointer x)) "((char*)x)[0] = 65; return(x);") "xBC"))

allows all types, I just want blob/string:

(print ((foreign-lambda* c-string ((scheme-pointer x)) "((char*)x)[0] = 65; return(x);") 45.0))

is there a "string" foreign type that works like "blob", that provides a (char*) argument and checks that argument is a string? Or is there a string->blob/shared procedure anywhere?

Thanks,
K.
(should this be moved to chicken-users, perhaps?)



On Wed, Jun 25, 2014 at 3:50 PM, Felix Winkelmann <address@hidden> wrote:
> I think I may have found a tiny bug in core. So instead of going on IRC and
> crying to Peter, I though I'd try it myself this time. I have a file like
> this:
>
> (print ((foreign-lambda* c-string ((blob x)) "x[0] = 65; return(x);")
> "xBC"))
>
> When I run this, everything works:
> $ ./type-test
> ABC
>
> However, I see a warning during compilation which I do not expect:
>
> $ csc type-test.scm
>
> Warning: at toplevel:
>   (type-test.scm:2) in procedure call to `g01', expected argument #1 of
> type `(or boolean blob)', but was given an argument of type `string'
>

You specify "blob" as foreign type but pass a string as the
argument. That the generated code works is just a coincedence - blobs
and strings have the same internal representation. You can use
"string->blob" to convert the argument to a blob object.


felix


reply via email to

[Prev in Thread] Current Thread [Next in Thread]