[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: List: forEach: arg1;
From: |
Kevin Crowston |
Subject: |
Re: List: forEach: arg1; |
Date: |
Wed, 5 Mar 1997 08:05:11 -0500 |
"Ludo Pagie" <address@hidden> wrote:
>-addConcentration: (double) c;
>[metabList forEach: M(addConcentration:) : myarg];
>with:
>
>>reaction.m: In function `_i_Reaction__react_':
>>reaction.m:38: incompatible type for argument 4 of indirect function call
It helps to know that a message send is basically syntactic sugar for a
function call--the line above is (more or less) turned into the function
call:
_i_Reaction__react_(metabList, sel, M(addConcentration), myarg)
So argument four is myarg.
>without this line the program compiles (and runs) fine. I guess that the
>argument 4 is an argument of one of those (?) run-time function-calls (eg.
>"objc_msgSend" in Next Objective C, don't know about Swarms run-time system).
The incompatible type comes because the forEach:: expects to get id's as
arguments, and you're passing a double. I had similar problems in my
simulation. What I ended up doing was: (1) switching to float's, since
they're the same size as id's, at least on a Sun--you might want to verify
this on whatever you're using. (2) passing the float as an id--this was a
bit ugly, since it turns out you can't simply cast a float to a pointer.
What I ended up doing was taking a pointer to my float, casting it to a
pointer to an id, and deferencing the pointer... ugly at best. If I
remember correctly, it looked like:
(*((id*)(&f)))
There's probably a more elegant way, but I think this worked.
Kevin