Re: [racket-dev] ffi vectors

2010-09-30 Thread Eli Barzilay
Four minutes ago, Jay McCarthy wrote: > Okay. I'm kind of glad that I came up with the normal thing. > > I'll put it on my infinitely long list of TODO items to come back > and extend the ctypes so that they can specify both aspects of their > size. The problem is not in the ctypes, it is in the

Re: [racket-dev] ffi vectors

2010-09-30 Thread Jay McCarthy
Okay. I'm kind of glad that I came up with the normal thing. I'll put it on my infinitely long list of TODO items to come back and extend the ctypes so that they can specify both aspects of their size. Jay On Thu, Sep 30, 2010 at 7:25 PM, Matthew Flatt wrote: > I guess I misunderstood what you

Re: [racket-dev] ffi vectors

2010-09-30 Thread Matthew Flatt
I guess I misunderstood what you were looking for. It would be nice to have a compact ctype that adapts like the C array type to different contexts. For my FFI tasks, I've gotten by with structure types like `_float4'; I manually choose between `_float4' or `_float4-pointer' as needed in different

Re: [racket-dev] ffi vectors

2010-09-30 Thread Jay McCarthy
Yes, but this program: typedef float float4[4]; typedef struct { float4 a; float b; } astruct; void go(float4 a, astruct b) { printf("in go: %d\n", sizeof(a)); printf("in go: %d\n", sizeof(float4)); printf("in go: %d\n", sizeof(b)); printf("in go: %d\n", sizeof(astruct)); } int m

Re: [racket-dev] ffi vectors

2010-09-30 Thread Matthew Flatt
When you run this program on a 32-bit machine: #include void go(float a[4]) { printf("in go: %d\n", sizeof(a)); } int main() { float a[4]; printf("in main: %d\n", sizeof(a)); go(a); } you'll see "in main: 16" and "in go: 4". As far as I know, the "4" in " void go(float a[4])

[racket-dev] ffi vectors

2010-09-30 Thread Jay McCarthy
I'd like to be able to define ctypes like I would make a typedef in C like typedef float float4[4]; But it doesn't seem like this works in the FFI. See the program below with its awkward work-around: #lang racket (require ffi/unsafe ffi/unsafe/cvector ffi/vector