Re: How can I pass an atom to a C function as C float or double
- Posted by jbrown105 at speedymail.org Sep 13, 2003
- 344 views
On Sat, Sep 13, 2003 at 10:49:25AM -0400, euman at bellsouth.net wrote: > > I dont know what the deal is with my mail being delivered html. > sorry folks, I'll get right on that problem too, didnt start till this > morning. > > Is this better Elliott? Robert? > > (C DLL) > her_dll > float CRoutine( float parameter1, double parameter2 ); > > (Euphoria code) > atom junk, x, y > x = 0.45 > y = 0.4534 > junk = allocate(16) -- 4 (float) + 8(Double) > poke(junk, atom_to_float32(x)) > poke4(junk+4, atom_to_float64(y)) > > constant > Myfunction = define_c_func(her_dll,"CRoutine",{C_FLOAT, C_DOUBLE}, C_FLOAT) > > f = c_func(Myfunction,{peek(junk),peek4u(junk+4)}) -- byref > f = c_func(Myfunction,{junk,junk+4}) -- byval Well, f = c_func(Myfunction, {junk,junk+4}) -- byREF would work as byref, but then the declaration would have to be constant Myfunction = define_c_func(her_dll,"CRoutine",{C_POINTER, C_POINTER}, C_FLOAT) and the C code would have to be float CRoutine( float * parameter1, double * parameter2 ); As for byval, you dont need the allocate() nor the atom_to_floatXX(), just call the function like so f = c_func(Myfunction,{x, y}) > > Hope this is more correct than the last post I made after 16 hours > behind this darn thing. Oh yeah, Thanks Elliott, Rob > > Euman > H2O Software, Inc. > > > > TOPICA - Start your own email discussion group. FREE! -- Outlook Users, please don't put my email address in your address book. That way, my email address won't appear in forged emails sent by email viruses. (Which are technically worms btw :P) -- Linux User:190064 Linux Machine:84163