[Top][All Lists]

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

Re: [Chicken-hackers] incorrect warning during compilation

From: Felix Winkelmann
Subject: Re: [Chicken-hackers] incorrect warning during compilation
Date: Fri, 27 Jun 2014 11:05:58 +0200 (CEST)

> 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?

You could also keep everything as it is and ignore the warning, but I
understand that it isn't the cleanest solution. I'm not aware of any
documented interchangability between strings and blobs, it is an
implementation artefact. "string->blob/shared" would make sense but is
not possible in the current implementation (srfi-4 vectors have an
indirection to the raw data buffer, there this conversion only changes
the wrapper object, but strings and blobs contain the data without the

So, I can't think of a solution that answers all of your questions.
I would go with the scheme-pointer. 

We could add another foreign type, that accepts strings but doesn't
copy. I'll look into that.


reply via email to

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