Re: Problems with C floats
- Posted by mattlewis (admin) Feb 01, 2010
- 2270 views
irv said...
void test_float(int *foo, double *bar, float *baz){
constant irv = open_dll( "./irv3.so" ), test1 = define_c_proc( irv, "test_float", {C_POINTER,C_POINTER,C_POINTER}), test2 = define_c_proc( irv, "test_float", {C_INT,C_DOUBLE,C_FLOAT})
This is the best I can do without knowing any C. Test 1 successfully passes values both ways. Test 2 crashes every time, no matter what values are sent.
Yes, I would expect test 2 to crash, because you're not passing pointers when that's what is expected by the C code. Actually, by abusing the concept of a double, you can "make it work" like this:
atom buffer = allocate( 8 ) poke4( buffer, ptr2 & ptr3 ) c_proc( test2, { ptr1, float64_to_atom( peek( buffer & 8 ) ), 0} )
Of course, that's not useful, but hopefully demonstrates a little what's going on there.
Actually, I'd really rather see the bit of EuGTK that's failing. Can you point me to something to download and try out? Something that's failing, that is?
Matt