|
From: | Germán Arias |
Subject: | Re: [Liberty-eiffel] How return a string to the C side |
Date: | Fri, 18 Nov 2016 00:56:23 -0600 |
First of all I beg your pardon for the late answer.
I encountered a similar issue wrapping the fork function.There are at least 2 causes that triggers that cast:
- the generated C file you invoke the call without or before a proper include of its definition, so the compile defines it implicitly, most often wrongly.
- the function is parameterless and the external feature does not have an explicit parenthesis. This is subtle because instead of calling the function you get the address of the code, usually already casted as an integer or as a void*. Something like
fork: INTEGER
-- function fork (in `/usr/include/unistd.h')
external "plug_in"
alias "{
location: "."
module_name: "plugin"
feature_name: "fork()"
}"
endHoping that it may help, and thanking for your effortsPaolo2016-11-17 7:17 GMT+01:00 Germán Arias <address@hidden>:
OK, I solved the problem. The string contains three integers. So,
instead return a string with the integers I use an IUP function to join
those integer in one integer, and then I return this new integer. At C
side, I use other IUP function the get the three integers (from the
returned integer) and make a char* string with these values. Then I can
return this array of chars.
Regards
Germán
El mié, 16-11-2016 a las 01:14 -0600, Germán Arias escribió:
> Hi,
>
> Most of the callbacks in eiffel-iup returns integers. But there is
> one
> callback that returns a char*. So I'm using a string and I try return
> this with my_string.to_external, but I get something like this:
>
> warning: cast to pointer from integer of different size [-Wint-to
> -pointer-cast]
>
> Is harmful this? How can eliminate this warning? Or maybe there is a
> better way to return a string. This is not a single char, is in fact
> a
> string. I don't have to much experience with C.
>
> Thanks
> Germán
>
>
[Prev in Thread] | Current Thread | [Next in Thread] |