The code is:
Push(size, (POINTER)(GetCar(i) == term_Null()? 0 : 1));
Here is the C code push
returns ABC
which is
typedef POINTER *ABC
typedef void * POINTER
ABC size;
Push(ABC,POINTER);
XYZ GetCar(int);
typedef struct xyz *XYZ;
XYZ term_Null();
long int i;
What is the reason for the particular warning?
Since this question uses the same typedefs as your 32bit to 64bit porting question I assume that you're using 64 bit pointers. As MByd wrote you're casting an int to a pointer and since int isn't 64 bit you get that particular warning.
You are trying to cast an integer value (0 or 1) to a void pointer.
This expression is always an int with value 0 or 1:
(GetCar(i) == term_Null()? 0 : 1)
And you try casting it to void pointer
(POINTER)
(typedef void * POINTER
).Which is illegal.
You can use
intptr_t
to ensure the integer has the same width as pointer. This way, you don't need to discover stuff about your specific platform, and it will work on another platform too (unlike theunsigned long
solution).Taken from the C99 Standard:
What are you trying to do? Pointers are not integers, and you are trying to make a pointer out of
0
or1
, depending on the situation. That is illegal.If you were trying to pass a pointer to a
ABC
containing0
or1
, use this: