Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

C language: error: cast from pointer to integer of different size

Status
Not open for further replies.

rih5342

Marine/Ocean
May 8, 2007
40
I'm using Windows-7 64bit, with gcc V5.2, with MinGW, and trying to compile portablexdr-4.9.1

This piece of C

static bool_t
xdrmem_setpos(xdrs, pos)
register XDR *xdrs;
u_int pos;
{
register caddr_t newaddr = xdrs->x_base + pos;
register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy;

if ((long)newaddr > (long)lastaddr) <== error here
return (FALSE);
xdrs->x_private = newaddr;
xdrs->x_handy = lastaddr - newaddr;
return (TRUE);
}

produces this error

xdr_mem.c: In function 'xdrmem_setpos':
xdr_mem.c:172:6: error: cast from pointer to integer of different size [-Werror=
pointer-to-int-cast]
if ((long)newaddr > (long)lastaddr)
^
xdr_mem.c:172:22: error: cast from pointer to integer of different size [-Werror
=pointer-to-int-cast]
if ((long)newaddr > (long)lastaddr)

How do I fix it?

Thank you.
 
Replies continue below

Recommended for you

Do you happen know what XDR and caddr_t are? (This is why I hate excessive typedef-ing. All it does is disguise what it's base-type truly is, which is not something you want to disguise anyway!)

It also looks like very old code. It's using the old-school function prototype.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor