Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > Problem with float parameters with CECIL.
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 2nd July 12:12
mathieu cuny
External User
 
Posts: 1
Default Problem with float parameters with CECIL.



Hello everybody !

I just encountered a problem while trying to use CECIL with ISE compiler
on Linux, and I was wondering whether anybody here might have already
seen it. It's my first try with CECIL, so i may not know everything which
is required...

I'm trying to call this Eiffel method from C.

set_values(px, py : REAL) is
...

So, i do something like

c_function(EIF_OBJECT e_object)
{
float value1, value2;

...values computations...

EIF_PROCEDURE proc;
proc = eif_procedure("set_angular_position", solar_system_type);
(proc)(eif_access(e_object), value1, value2);
}

in a function called by Eiffel, with e_objet set to current.
Actually, i followed CECIL array example, using floats instead of ints.
However, it did not seem to work with REAL. While the procedure is called
correctly, the values I get on C side are irrelevant, though they change
along C values.

I tried this code with INTEGER and int, and it worked flawlessly, like in
CECIL example. Is there someting special to do before using REAL and
floats ? I wouldn't have to revert to old style fixed decimal numbers.


By the way, i do that in order to do some calculations on C side, and get
the result back in Eiffel. Is there another way than using a set_values
procedure ? I haven't found a way to set a class attribute, since values
are copied when using eif_attribute.

Thanks,
Mathieu
  Reply With Quote


 


2 2nd July 12:12
emmanuel stapf [es]
External User
 
Posts: 1
Default Problem with float parameters with CECIL.



Instead try

((FUNCTION_CAST(void, (EIF_REFERENCE, EIF_REAL, EIF_REAL)) proc)
(eif_access (e_object), value1, value2);

and let us know if it works better.

Manu
  Reply With Quote


 


3 2nd July 12:12
mathieu cuny
External User
 
Posts: 1
Default Problem with float parameters with CECIL.


It works fine ! Thank you !
I guess i should have declared my Eiffel function in a .h file. Surely,
gcc used a default int type ?
  Reply With Quote
Reply


Thread Tools
Display Modes




666