I am currently working on porting from 32 bit to 64 bit. And I am getting a warning:
cast to pointer from integer of different size
In the following code
AcLogFileWrite(
(FILE *) pOut->pTrace->logFileHandle, /* warning in this line */
outRecord,
outRecordLen);
and prototype of AcLogFileWrite()
is
int AcLogFileWrite(
FILE * handle,
char * data,
int bytes);
Here the parameter pOut->pTrace->logFileHandle
is of type int
.
How can I fix this warning?
You can't store 64 bits in a 32-bit int. If logFileHandle
has to store a pointer, the only integer types that can safely do that are uintptr_t
or intptr_t
from <stdint.h>
. Or you can typedef void*
. Since you're porting to a new ABI anyway, binary compatibility is not an issue and this is a good time to fix it.
If you absolutely cannot change the definition of the type from int
, then you must compile under the ILP64
model, in which int
, long
and void*
are all 64 bits wide.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.