Re: How can I pass an atom to a C function as C float or double
myotis at xnet.ro wrote:
> Please tell me how can I pass an atom as a C float to a C
> function from a dll. The same question is for a C double ...
Elliott was correct in his message.
There are a couple of things to watch out for though...
> Example of the C function in DLL :
>
> float MyFunction( float parameter1, double parameter2 );
>
> I have tried all the posible combinations ( C_FLOAT in define the C
> function, atom_to_float32 when I pass the arguments ... nothing work )
Don't use atom_to_float32() for passing arguments.
Just pass the atom value directly as an argument.
> Please write to me a little piece of euphoria code that call this
> function in Euphoria. Also tell me the calling convention you are write
> for ...
> I can change this in my DLL as I want.
I recommend that you use the __stdcall calling convention
when defining the C routine that you are calling from Euphoria.
There's a problem when you try to return a floating-point value
to exw.exe using the other convention, __cdecl.
Watcom C (used to build exw.exe) doesn't handle floating-point
return values correctly when it's __cdecl. __cdecl is the
default convention with most C compilers. (If you translate
your program to C, and compile with Borland, it should be ok.)
> Also, please tell me if the version of euphoria you are
> writeing for the example, matter for some reason.
2.3 should work fine,
but 2.4 has some enhancements in this area,
such as __cdecl support (for most things),
error tracebacks when a machine-level exception happens,
enhanced define_c_proc()/func(), etc.
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
|
Not Categorized, Please Help
|
|