On the 64-bit machine:
sizeof(int) = 4
sizeof(ssize_t) = 8
You already pointed out the drawback of casting int* into ssize_t* in
case ss-ze_t is larger.
ssize_t is declared in unistd.h or stddef.h so it wouldn't always be
possible to do it.
Given the constraints we had... we made a cheap fix... because we knew
what the code does (we knew that the calculation 'values' will fit in
an int):
ssize_t tmp = a.i;
f(&tmp);
a.i = (int) tmp;
:)
Regards,
Jyoti
On May 21, 11:23 pm, SUDHEER DURUSOJU <
sdurus...@gmail.com> wrote:
> I think word length of the machine is playing a role in generating
> compilation error. ssize_t and int might be getting different bytes
> allocated on 64 bit machine.
>
> What is the result of sizeof(int) and sizeof(ssize_t) on 64-bit machine?
>
> One non-preferred way of solving this is to type cast the pointer when
> calling it. Call the function like f((ssize *)&(a.i)). This has the problem
> of accessing wrong portion of memory if the allocated sizes doesn't match
>
> Other method is to use
>
> *typecast int ssize_t* in main() so that ssize_t will be also represented as
> int. I am guessing this, did not tired it :)
>
> -Sudheer
>